You can set certain commands and scripts to run automatically on a set schedule – as regularly as once an hour or as rarely as once a year.
These scheduled tasks are also known as cron jobs, and can be set to run on an hourly, daily, weekly, or monthly basis.
You can set up to three cron jobs in your eXtend Control Panel. If you need more automatic commands, you can run the cron job on a script that executes the commands you need.
When you set up the cron job, you need to specify the interpreter – the version of the language you are using – as well as the script. You can find the paths to the versions of the languages available in 'Paths and Versions' under 'Website Help & Diagnostics' in your eXtend Control Panel.
When you know your path and version for your interpreter, you then write your cron job in this format:
/[INTERPRETER] /[FILE] [ARGUMENT]
Where [INTERPRETER] is the path to the right version of the language, [FILE] is the script you want to run, and [ARGUMENT] are the arguments for the script.
If you wanted to run a particular PHP file, the cron job would be:
/usr/bin/php /home/sites/your-domain.com/public_html/cron.php task=tidy owner=1
To set up your cron job:
- Log into your eXtend Control Panel
- Click on 'Scheduled Tasks' under 'Web Tools'
- Either pick the script file you wish to run, or enter in the command you want to run
- Click 'Test Command' to test your command
- Select the time you want the task to run
- Click 'Update'
- The command will now run at the time you have specified
When you pick a numerical value for the cron job (such as Day, Hour, or Minute), the value is the time it will run, not the number of times it will run. For example, if you select “19 minutes” under the Minute value for your cron job, it will not run every 19 minutes, but will start on the 19th minute past the hour.