crontab [ -u user ] file
crontab [ -u user ] { -l | -r | -e }
Each user has their own crontab located in /var and is not to be edited directly.
file will replace the existing crontab
-u user whose crontab is to be used.
Do not su and run crontab use the -u option.
-l list
-r remove
-e edit using the editor specified by the VISUAL or EDITOR environment variables.
It is best to avoid using crontab -e. Create a local file then use crontab filename to install it.
If /etc/cron.allow exists, then only listed users have active crontabs
If /etc/cron.allow does not exist and /etc/cron.deny exists, listed users crontabs will not be used.
If neither files exists site configuration can specify that only super
user or all users can have active crontabs.
Blank lines and leading spaces and tabs are ignored.
# lines are comments
Comments are not allowed on the same line as commands.
Comments are not allowed on the same line as environment variable settings.
Each line is either a CRON COMMAND or an ENVIRONMENT SETTING.
Each CRON COMMAND has
minute (0-59) hour (0-23) day_of_month (1-31) month (1-12) day_of_week (0-7 (0 and 7 are Sunday)
* can be used for every.
Inclusive RANGEs are numbers separated with a hyphen. Example: 9-17 for hours 9, 10, 11, 12, 13.
A LIST of numbers (or ranges) seperated by commas can be used. Example: 7,9-11,13-17,21
Use /number for STEP VALUES to skip the value with RANGEs.
This skips the number's value through the
range. For example, 0-23/2 specifies every other hour .
Steps are permitted after an asterisk, for every two hours, use */2.
NAMES can be used for the month and day of week, case-insensitive, first three letters.
RANGES or LISTS of NAMES are not allowed.
/bin/sh or
by the shell specified in the $SHELL variable of the cronfile. %s unless escaped with backslash, are replaced with newline characters, and
data after the first % will be sent to the command as standard input.
The command is executed when any of the two day fields (day of month, or day of week) and the current time match.
Note non-existant times, such as "missing hours" not match, No validation is done on ANY field, including testing for legal time,dates or even legal characters.
Note: The day of a command's execution can be specified by two fields : day of month, and day of week. If both fields are restricted (ie, are' *), the command will be run when either field matches the current time. For example, ''30 4 1,15 * 5'' would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.
An ENVIRONMENT SETTING is of the form, name = value
spaces around the = are optional, embedded spaces in value will be part of the value.
The value string may be placed in apostrophes or quotes (single ) to preserve blanks.
$SHELL is set to /bin/sh, $LOGNAME and $HOME are set from the
/etc/passwd line of the crontab's owner are set up automatically by the cron(8).
$HOME and $SHELL may be overridden by settings in crontab.
(LOGNAME variable is sometimes called USER on BSD systems... on these systems, USER will be set also.)
STDOUT from the command is mailed to the owner of the crontab.
Use MAILTO to send it to another user.
If MAILTO is empty (MAILTO="", no mail will be sent.
Used if you decide on /bin/mail instead of
/usr/lib/sendmail you install cron -- /bin/mail
doesnt do aliasing.
EXAMPLE CRON FILE
# use /bin/sh to run commands, no matter what /etc/passwd says
SHELL=/bin/sh
# mail any output to 'paul', no matter whose crontab this is
MAILTO=paul
#
# run five minutes after midnight, every day
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
# run at 2:15pm on the first of every month -- output mailed to paul
15 14 1 * * $HOME/bin/monthly
# run at 10 pm on weekdays, annoy Joe
0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
5 4 * * sun echo "run at 5 after 4 every sunday"
/etc/crontab System crontab file.Uucp and News will usually have their own crontabs . UUCP usually does' read its mail.
0 and day 7 are considered Sunday.
Lists and ranges can be used in the same field. 1-3,7-9
Ranges can include "steps", so 1-9/2 is the same as "1,3,5,7,9".
months or days of the week can be specified by name.
During daylight savings conversion can cause jobs to be skipped when time is advanced or executed multiple times when time is reset.
4th Berkeley Distribution
crontab program 29 December 1993
crontab file 24 January 1994 CRONTAB(5)
AUTHOR Paul Vixie