Cron

Introduction

The software utility cron is a time-based job scheduler in Unix-like computer operating systems. People who set up and maintain software environments use cron to schedule jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals. It typically automates system maintenance or administration—though its general-purpose nature makes it useful for things like connecting to the Internet and downloading email at regular intervals. The name cron comes from the Greek word for time, χρόνος chronos.

Usage

Compute Systems Invocation Version(s)
Red Hat Linux (64-bit) % /usr/bin/crontab Varies by system (default)

crontab Record Format

A crontab file is a table of cron commands.

Field Description Range
minute Minute of the hour [0 .. 59]
hour Hour of the day [0 .. 23]
day Day of the month [1 .. 31]
month Month of the year [1 .. 12]
weekday Day of the week [1 .. 7] (where 1 == Monday, 7 == Sunday)
command Command or script that is scheduled to run Command and options or Fully-qualified file name and options

crontab Sample Record

At 8:15 every morning, run the shell script /usr/local/bin/basis.cards. Pipe its output into an email message whose subject header is "basis.cards". Send it to user cwmiller in the default email domain.


# BASIS: Update all users' access level privileges
15 8 * * *	/usr/local/bin/basis.cards | /bin/mail -s "basis.cards" cwmiller

Notes

  1. You may need to set your EDITOR environment variable before running crontab so cron knows which editor you prefer to use to edit your crontab file.
    
    % setenv EDITOR vi
    
    
  2. List your crontab records:
    
    % /usr/bin/crontab -l
    
    
  3. Edit your crontab records:
    
    % /usr/bin/crontab -e
    
    

References

  1. http://en.wikipedia.org/wiki/Cron
  2. % man cron
  3. % man crontab