CRON(C) XENIX System V CRON(C)
Name
cron - Executes commands at specified times.
Syntax
/etc/cron
crontab [file]
crontab -r
crontab -l
Description
cron is the clock daemon that executes commands at specified
dates and times according to the instructions in the files
located in /usr/spool/cron/crontabs. Regularly scheduled
commands can be specified according to instructions found in
crontab files; users can submit their own crontab file via
the crontab command. Commands which are to be executed only
once may be submitted via the at(C) command. Because cron
never exits, it should be executed only once.
crontab copies the specified file, or standard input if no
file is specified, into a directory that holds all users'
crontabs. The crontab file in the crontabs directory is
given the user's login name. The -r option removes a user's
crontab from the crontab directory. crontab -l will list
the crontab file for the invoking user.
A user is permitted to use crontab if their name appears in
the file /usr/lib/cron/cron.allow. If that file does not
exist, the file /usr/lib/cron/cron.deny is checked to
determine if the user should be denied access to crontab.
If neither file exists, only root is allowed to submit a
job. Global usage is permitted by the existence of an empty
cron.deny file. cron.deny is checked only if cron.allow does
not exist. The allow/deny files consist of one user name
per line.
The crontabs files consist of lines of six fields each. The
fields are separated by spaces or tabs. The first five are
integer patterns that specify the minute (0-59), hour (0-
23), day of the month (1-31), month of the year (1-12), and
day of the week (0-6, with 0=Sunday). Each of these
patterns may contain:
- A number in the (respective) range indicated above
- Two numbers separated by a minus (indicating an
inclusive range)
Page 1 (printed 2/7/91)
CRON(C) XENIX System V CRON(C)
- A list of numbers separated by commas (meaning all of
these numbers)
- An asterisk (meaning all legal values)
Note that the specification of days may be made by two
fields (day of the month and day of the week). If both are
specified as a list of elements, both are adhered to. For
example, 0 0 1,15 * 1 would run a command on the first and
fifteenth of each month, as well as on every Monday. To
specify days by only one field, the other field should be
set to * (for example, 0 0 * * 1 would run a command only on
Mondays).
The sixth field is a string that is executed by the shell at
the specified time(s). A % in this field is translated into
a newline character. Only the first line (up to a % or
end-of-line) of the command field is executed by the shell.
The other lines are made available to the command as
standard input.
The shell is invoked from your $HOME directory with an arg0
of sh. Users who desire to have their .profile executed
must explicitly do so in the crontab file. cron supplies a
default environment for every shell, defining HOME, LOGNAME,
SHELL(=/bin/sh), and PATH(=:/bin:/usr/bin).
cron examines the crontabs directory periodically to see if
it has changed; if it has, cron reads it. Thus it takes
only a short while for entries to become effective.
crontab exits and returns a value of 55 if it cannot
allocate enough memory. If it exits for any other reason,
it returns a value of 1.
Examples
An example crontabs file follows:
30 4 * * * /etc/sa -s > /dev/null
0 4 * * * calendar -
15 4 * * * find /usr/preserve -mtime +7 -a -exec rm -f {} ;
40 4 * * * find / -name '#*' -atime +3 -exec rm -f {} ;
1,21,41 * * * * (echo -n ' '; date; echo ) >/dev/console
A history of all actions by cron can be recorded in
/usr/lib/cron/log. This logging occurs only if the variable
CRONLOG in /etc/default/cron is set to YES. By default this
value is set to NO and no logging occurs. If logging should
be turned on, be sure to monitor the size of
/usr/lib/cron/log so that it doesn't unreasonably consume
disk space.
Page 2 (printed 2/7/91)
CRON(C) XENIX System V CRON(C)
Files
/usr/lib/cron main cron directory
/usr/spool/cron/crontabs/* spool area
/usr/lib/cron/log accounting information
/usr/lib/cron/cron.allow list of allowed users
/usr/lib/cron/cron.deny list of denied users
/usr/lib/cron/.proto cron environment information
/usr/lib/cron/queuedefs cron data file
/etc/default/cron cron logging default information
See Also
at(C), sh(C)
Notes
cron reads the files in the crontabs directory only when
there is a change, but it reads the in-core version of the
tables periodically.
Users should remember to redirect the standard output and
standard error of their commands, otherwise any generated
output or errors will be mailed to the user.
crontab will overwrite any previous entry with the same
name. To modify an existing crontab file, use crontab -l to
copy it to a file, edit the file, then resubmit it with
crontab.
Page 3 (printed 2/7/91)