Doc tools: Log in
Cron is a job scheduler, a utility that can be used to execute shell commands at specific points in time. These jobs are also called Cron jobs, and can be edited using the crontab command.
To edit the cron table (crontab) file, you will use the crontab command. The crontab command has a few options:
crontab -e: Edit the crontab for the current user
crontab -l: List the cron jobs for the current user
crontab -r: Remove all cron jobs for the current user (Use the -i option to prompt before deleting)
Perform these steps to edit the crontab.
To add a new line to the file, you should follow this format:
┌───────────── minute (0 - 59) │ ┌───────────── hour (0 - 23) │ │ ┌───────────── day of month (1 - 31) │ │ │ ┌───────────── month (1 - 12) │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday; │ │ │ │ │ 7 is also Sunday) │ │ │ │ │ │ │ │ │ │ * * * * * command to execute
You can use an asterisk (*) if a field does not matter. For example:
0 * * * * python somescript.py
python somescript.py every hour.
1 0 15 * 0 somecommand
somecommand every month the 15th day or if the day is a Sunday, at 1 past midnight (00:01).
Drush and Cron can be used to update Drupal automatically.
crontab -ecommand. More info can be found in the previous section.
0 0 * * * cd /path/to/your/drupal/folder/ && drush pm-update -l http://your.website.url
This will execute the
cd /path/to/your/drupal/folder/ command, changing the current directory to your drupal folder, and the
drush pm-update -l http://your.website.url command, updating Drupal, every day, at midnight. The
&& indicates a new command follows.