CSL: Crontabs

CSL: Crontabs

cron is background system process that will run scheduled commands without user intervention. Virtually any program or script which can be run manually can be run as a "cron" job. This document provides only basic reference to the cron utility as well as providing CS-specific details.

It is possible for crontabs to be accidentally erased from system areas. Therefore, it is a good practice to keep a copy of any of your crontabs in your home directory. We also recommend running your crontabs from the centralized server cron.cs.duke.edu, as opposed to individual desktop machines; if the desktop machines break or are replaced, your cron jobs will not be saved. Below are examples of saving your existing crontabs and loading your saved crontabs into your home directory:

Saving existing crontabs
user@cron> crontab -l > crontab.save
Loading saved crontabs
user@cron> crontab < crontab.save

Please see the crontab man page for more information.

Sample crontab entry

Here is a sample crontab entry:

     0 0,8,12,16,20 * * * /home/user/bin/myscript

This entry tells the cron utility to run myscript on the hour at midnight, 8am, noon, 4pm, and 8pm every day of the week. For more information about the time format used, please see the crontab configuration man page for more information. If the script produces any output, cron will email you the result.