Skip to content Skip to navigation

Instructions for the dedicated grizzled technologist

Posted by: 

Note: The Scheduling Service is now live at (look under Web Services, Scheduling Service) and it's a much easier way to accomplish the goals outlined below.

cron jobs are created from the (unix) command line with the *crontab* command.

Documentation within the site is woefully confusing, but is helpful in that one quickly realizes that everyone finds crontab difficult. Here are the most common solutions (outside Stanford) none of which require messing with crontab:
* ISP handles this for their client
* admins set this up using cpanel
* poor man's cron module (Drupal) []
* use of wget instead of cron

Instructions below are for the dedicated grizzled technologist who wants to setup their own crontab on Leland (by god\!)

Background reading

* [] \- read this to comiserate with others having problems
* [] \- this is actually useful
* *man crontab* from a Unix shell

What the cron job does

* crontab creates a crontab file that runs a script on a regular time interval (cron = chronograph)
* in the case of Drupal, this calls a file **
* is a shell script that uses the lynx web browser to ping your site's cron.php which indexes the site, and keeps various contrib modules happy
* Cron does things like re-building the index of the database. Some modules use cron to update their information, call APIs etc.

contents of the file:

/usr/bin/lynx \-source [] > /dev/null 2>&1

Changes need to be made to this file
* the path to lynx needs to be changed to the Stanford specific path: /usr/pubsw/bin/lynx (you can verify the location of lynx by typing *which lynx* at the shell)
* the location of the cron.php needs to be changed

example cron code

* 00 * * * * /path/to/scripts/

setting up crontab

* option 1: type *crontab \-e* from command line and type cron code (1 line in this case) directly into the text editor that launches
* option 2: load cron job from file (ZC: this is what I did, seems safer) refer to link above


* once your crontab is set, you may need to fix permissions so that the crontab "user" can access
* the cron job will be run as you (i.e. the user that typed *crontab \-e*)
* if is installed in AFS space, even though the cron job runs as you, it will not have access to the AFS credentials necessary to read the file (and you won't know an error occurred because output is discarded by the command in So, the simplest solution is to make executable and place it in a directory that is readable by system:anyuser. Obviously, don't put any other files in there and nothing of a sensitive nature. Better yet, use JRJ's instructions below which bypass AFS issues and use wget which is more lightweight than lynx.