Cron jobs

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.

  • 0 Els usuaris han Trobat Això Útil
Ha estat útil la resposta?

Articles Relacionats

Creating a simple, safe contact form

If you've ever wanted a feedback or contact form on your website, you may find the following code...

File permissions

There are a number of file permissions, which can be used for a variety of different purposes,...

How do I create a custom php.ini file?

A custom php.ini file can be constructed and placed in your web account. For instance, using a...

How to change the date.timezone value in PHP?

If your PHP scripts do not show the correct time, the reason is that most probably your hosting...