crontab
PURPOSE
Submits a schedule of commands to cron.
SYNOPSIS
crontab [ file ]
crontab -l
crontab -r
DESCRIPTION
The crontab command copies the specified file, or
standard input if you do not specify a file, into a
directory that holds all users' crontab files. The cron
command runs commands according to the instructions in
these crontab files. It then mails you the output from
standard output and standard error for these commands,
unless you redirect standard output or standard error.
When entries are made to a crontab file, all previous
entries are erased.
You may use crontab if your logname appears in the file
/usr/lib/cron/cron.allow. If that file does not exist,
crontab checks the file /usr/lib/cron/cron.deny to deter-
mine if you should be denied access to crontab. If
neither file exists, you can submit a job only if you are
operating with superuser authority. The allow/deny files
contain one user name per line.
Notes:
1. If your login ID is associated with more than one
login name, crontab uses the first login name that
appears in the /etc/passwd file, regardless of which
login name you might actually be using.
2. If cron.allow exists, the superuser's logname must
appear there for the superuser to be able to use the
command.
Each crontab file entry consists of a line with six
fields, separated by spaces and tabs, that contain,
respectively:
1. The minute (0-59)
2. The hour (0-23)
3. The day of the month (1-31)
4. The month of the year (1-12)
5. The day of the week (0-6 for Sunday-Saturday)
6. The shell command.
Each of these fields can contain:
o A number in the specified range
o Two numbers separated by a minus to indicate an
inclusive range
o A list of numbers separated by commas, which selects
all numbers in the list
o 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 you
specify both as a list of elements, both are adhered to.
For example the following entry:
0 0 1,15 * 1 command
would run command on the first and fifteenth days of each
month, as well as every Monday. To specify days by only
one field, the other field should contain an "*".
The cron command runs the command named in the sixth
field at the selected date and time. If you include a
"%" (percent sign) in the sixth field, cron treats every-
thing that precedes it as the command invocation and
makes all that follows it available to standard input,
unless you escape or quote the percent sign ("\%" or
""%"").
Note: The shell runs only the first line of the command
field (up to a "%" or end of line). All other lines are
made available to the command as standard input.
The cron command invokes a subshell from your $HOME
directory. This means that it will not run your .profile
file. If you schedule a command to run when you are not
logged in and you want to have commands in your .profile
run, you must explicitly do so in the crontab file. (For
a more detailed discussion of how sh can be invoked, see
"sh").
cron supplies a default environment for every shell,
defining HOME, LOGNAME, SHELL (="/bin/sh"), and PATH
(=":/bin:/usr/bin").
FLAGS
-l Lists your crontab file.
-r Removes your crontab file from the crontab direc-
tory.
EXAMPLES
The following examples show valid crontab file entries.
1. To write the time to the console every hour on the
hour:
0 * * * * echo The hour is `date`. >/dev/console
This example uses command substitution. For more
information, see "Command Substitution."
2. To run calendar at 6:30 a.m. every Monday, Wednesday,
and Friday:
30 6 * * 1,3,5 /usr/bin/calendar -
3. To define text for the standard input to a command:
0 16 10-31 12 5 /etc/wall%HAPPY HOLIDAYS!%Remember to turn in your time card.
This writes a message to all users logged in at 4:00
p.m. each Friday between December 10th and 31st.
The text following the "%" (percent sign) defines the
standard input to the wall command as:
HAPPY HOLIDAYS!
Remember to turn in your time card.
FILES
/usr/lib/cron Main cron directory.
/usr/spool/cron/crontabs Spool area.
/usr/lib/cron/cron.allow List of allowed users.
/usr/lib/cron/cron.deny List of denied users.
RELATED INFORMATION
The following commands: "cron" and "sh."