ARCHIVED: Cron: Schedule jobs on the IU WWW servers

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

On this page:


Overview

  • 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 do not need to request cron, as all accounts on Webserve are automatically enabled for its use.

Create the cron files

  1. The files you create will be placed in the bin subdirectory in your login directory. (If you prefer, you may place them in another directory, but not inside either the www or wwws directory.)

    To create the bin subdirectory, log into your account and type mkdir bin. It's no problem if you receive a message that the directory already exists.

  2. To move to that directory, type cd bin.

    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.

    The second file contains the directives to the cron job scheduling system that will cause your script to 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 account, then the filename would be account.crontab. You should also adjust the output of your cron application to a file or /dev/null; for example, suppose your crontab had the following entry at the end of the line:

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

    You can have the output piped to a file by adding:

    0 * * * * /ip/account/bin/my_cron_app.pl >> /ip/account/bin/my_cron_app_output.log 2>&1

    Above, the >> 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/account/bin/my_cron_app.pl > /dev/null  2>&1
  3. To submit your crontab file, account.crontab, to the cron system, enter crontab account.crontab. After you make changes to your crontab file, you have to re-submit it.

Identify existing cron jobs

If you are an account owner who has lost track of your existing crontab file, to examine any cron entries for an account, log into your account on Webserve via SSH and enter:

crontab -l

To pipe this to a new crontab file, use:

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

If you receive the message below, you do not have cron jobs set up for that account:

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

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

man crontab

This is document bfsk in the Knowledge Base.
Last modified on 2021-09-08 10:22:10.