Indiana University

IU Webmaster

Cron: Scheduling Jobs on the IU WWW Servers

Table of Contents

Introduction

Creating the cron files

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.

Identifying existing cron jobs

For account owners who have lost track of their existing crontab file, to examine any cron entries for an account, login to your account on Webserve via SSH and type:

crontab -l

You can also pipe this to a new crontab file using:


crontab -l > crontab.file (a file name of your choice)

Note: If you receive the following message:

You (account) are not allowed to use this program (crontab)
See crontab(1) for more information

this means that you do not have cron jobs set up for that account.

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

man crontab