This article applies to 123 Reg Linux Dedicated Servers.
Basic Commands
When logged in to the SSH terminal for your dedicated server, the crontab command allows viewing or editing of the file from where your cronjobs will run. crontab -e – Run this command to edit your crontab file, or create one if it does not already exist. crontab -l – Run this command to display your current crontab file.Cron Syntax
A crontab file has five fields for specifying day date and time, followed by the command to be run at that interval as demonstrated below.
* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
30 18 * * * rm /home/username/tmp/*
Executing PHP scripts using Cron
A number of our users require their PHP scripts to be executed within a schedule. This too can be achieved using a cronjob however you will need to specify the PHP script engine that should be used to execute the script. For example, if you wanted to run your PHP script every 10 minutes of every day, you should add the cronjob in the following format.
*/10 * * * * /usr/bin/php5 /path/to/your/script.php
Please note: Cronjobs are configured at the users own risk. If you are in any doubt with regards to configuring cronjobs on your dedicated server, please contact the 123 Reg support team.