Categories
Categories
Cron jobs Print
- 94
A 'cron job' is an automated task that can be set up within your cPanel. This will typically be used to automate the running of a reminder script each day for example, or perhaps to run your own daily backup script. Any server task or script that needs regular scheduling is the perfect opportunity to use a cron job.
We would ask that you be sparing with your use of cron jobs however, as a resource-intensive script executing every five minutes for example would clearly breach our acceptable use policy. Our recommendation would be to schedule cron jobs to run only as and when they are needed.
Your online cPanel allows for the creation of cron jobs via a simple web interface. This is presented in plain english, and requires little understanding to operate.
If you decide to use the "Advanced" option however, the following information may assist you in understanding how the system works.
Understanding the format
r----Minute
| r-----Hour
| | r------Day of Month
| | | r------Month
| | | | r------Day of Week
| | | | | |------ Command to run ------------->
| | | | | |
5 4 * * 0 /path/to/whatever/script.cgi
The * symbol matches all possibilities. A "*" in the "Hour" column will for example ensure that the job is run every hour, on whichever minute(s) are specified.
The weekday number runs from 0 to 6, where 0 = Sunday.
Comma-separated values are accepted in each column, so "10,30,50" in the "Minute" column will run the cron job at 10 past, 30 past and 50 past whichever hour(s) are specified. Similarly, a value of */5 will ensure the job is run every five minutes on whichever hour(s) are specified.
Examples
5 4 * * 0 /path/to/whatever/script.cgi
Runs the script at 4:05 every sunday.
*/5 * * * * lynx --dump http://site.com/script.php
Loads the page http://site.com/script.php every 5 minutes.
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out
Runs five minutes after midnight, every day
Note: These timings correspond to the server time, which may differ from your local time.