Indiana University

IU Webmaster

Cron: Scheduling Jobs on the IU WWW Servers

  • It is possible to schedule the execution of UNIX shell scripts (written in the syntax of the csh, ksh, or sh shells), Perl scripts, C scripts, etc. from your central WWW server account.

  • You need to fill out a Request to Enable Cron. To access this form, you will need to authenticate using your IU Network ID and password. This form must be submitted by either the sponsor or contact of record only.

Step 1: You will need to create two files that should be placed into a subdirectory called bin in your login directory. (If you prefer, you may place it in another directory but you should not place it inside either the www or wwws directory.)

  1. To create the bin subdirectory, just login to your account and type: mkdir bin. If you receive a message that the directory already exists, that's OK.

  2. Move to the bin directory. Type cd bin.

Step 2: Now back to the two files you need to create.

  1. The first file is a shell/Perl/C script that contains the commands you wish to have executed on a schedule by the cron system.

  2. The second file contains the directives to the 'cron' job scheduling system that will cause your script to be run at the desired time on the desired days. A shorthand name for this file is the 'crontab' (for cron table) file for your account.

    The file should have a name which is the name of your account followed by .crontab. If my account name is: myaccount, then the filename would be: myaccount.crontab

    You should also adjust the output of your cron application to a file or /dev/null. For example, if your crontab had the following entry:

    0 * * * * /ip/myaccount/bin/my_cron_app.pl
    

    at the end of the line, you can have the output piped to a file by adding:

    0 * * * * /ip/myaccount/bin/my_cron.pl >> /ip/my_account/bin/my_cron.pl 2>&1
    

    The '>>' above appends to the log file; a single '>' will cause the file to be overwritten. If you never want to see the output, pipe to /dev/null:

    0 * * * * /ip/myaccount/bin/my_cron.pl > /dev/null  2>&1
    

Step 3: Now you need to submit your crontab file, myaccount.crontab, to the 'cron' system. Type crontab myaccount.crontab. After you make changes to your crontab file, you have to re-submit it.

To see additional information, while logged into your account type:

man crontab