Version 3 (modified by Jamie McClelland, 11 years ago) (diff)


How do I add a cron job?

A cron job is a command that runs repeatedly at a given time. Often, cron jobs are set to run tasks like updating your web site statistics once an hour, or backup your data every day, or access your Drupal installation's cron.php script on a regular basis.

To set a cron job, you will need to access your server using a secure shell program. Please refer to our secure shell page for information about how to run secure shell on your computer.

Once you have connected via secure shell to your primary server, you can create a cron job by typing:

crontab -e

After typing this command, a text editor program will open, prompting you to enter your crontab information.

The crontab syntax is a series of space separated numbers or asterisks, followed by the command you want to run. For example:

5 * * * * /usr/bin/curl --silent --compressed

The first five items (in this case: 5 * * * *) refers to when the cron job should be run. The columns are: minute, hour, day of month, month, day of week. An asterisk means always run. So, in the example above, it says, run at 5 minutes after the hour, every hour, every day, every month and every day of the week. Similarly, typing (5 8 * * *) would mean to run at 8:05 every day.

Everything after the numbers and asterisks is the command to be run. In this example, it means: access the script.