Cron jobs on comprehensive web hosting

It is possible to use cron on the web hosting server, but not on access.nsms.ox.ac.uk where cron is disabled. To run a cron job, create a file called crontab in the directory <site>/cron on access.nsms.ox.ac.uk. The web server will then copy this into place, as this file is synchronised once every 5 minutes.

The  <site>/cron/crontab file should follow the usual syntax for crontab files. An internet search for 'crontab examples' may also provide helpful examples.

N.B. Users are strongly recommended to set an email address where the output of tasks will be sent. This can be done by adding MAILTO=your@email.address to your crontab file; if you do not do this, you will not receive any output from your jobs.

One example of this is to enable the polling of cron jobs on a Drupal site every 15 minutes. To do this (using curl) you would create the file sitename.ox.ac.uk/cron/crontab with contents:

# Set recipient email address for task output
MAILTO='first.last@unit.ox.ac.uk'

# Poll Drupal cron every 15 minutes
15/* * * * * curl --silent -o /dev/null http://site.ox.ac.uk/cron.php

Note you can also use wget rather than curl to do this.

Service area: 

Written by IT Services. Latest revision 27 May 2016