Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/cron/crontab/crontab.5
Show First 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | |||||
Names can also be used for the ``month'' and ``day of week'' | Names can also be used for the ``month'' and ``day of week'' | ||||
fields. | fields. | ||||
Use the first three letters of the particular | Use the first three letters of the particular | ||||
day or month (case does not matter). | day or month (case does not matter). | ||||
Ranges or | Ranges or | ||||
lists of names are not allowed. | lists of names are not allowed. | ||||
.Pp | .Pp | ||||
The ``sixth'' field (the rest of the line) specifies the command to be | The ``sixth'' field (the rest of the line) specifies the command to be | ||||
run. | run. One or more command options may precede the command to modify | ||||
processing behavior. | |||||
The entire command portion of the line, up to a newline or % | The entire command portion of the line, up to a newline or % | ||||
character, will be executed by | character, will be executed by | ||||
.Pa /bin/sh | .Pa /bin/sh | ||||
or by the shell | or by the shell | ||||
specified in the | specified in the | ||||
.Ev SHELL | .Ev SHELL | ||||
variable of the cronfile. | variable of the cronfile. | ||||
Percent-signs (%) in the command, unless escaped with backslash | Percent-signs (%) in the command, unless escaped with backslash | ||||
(\\), will be changed into newline characters, and all data | (\\), will be changed into newline characters, and all data | ||||
after the first % will be sent to the command as standard | after the first % will be sent to the command as standard | ||||
input. | input. | ||||
.Pp | .Pp | ||||
The following command options can be supplied: | |||||
.Bl -tag -width Ds | |||||
.It Fl n | |||||
No mail is sent after a successful run. | |||||
The execution output will only be mailed if the command exits with a non-zero | |||||
exit code. | |||||
The | |||||
.Fl n | |||||
option is an attempt to cure potentially copious volumes of mail coming from | |||||
.Xr cron 8 . | |||||
.It Fl q | |||||
Execution will not be logged. | |||||
.El | |||||
Duplicate options are not allowed. | |||||
.Pp | |||||
Note: The day of a command's execution can be specified by two | Note: The day of a command's execution can be specified by two | ||||
fields \(em day of month, and day of week. | fields \(em day of month, and day of week. | ||||
If both fields are | If both fields are | ||||
restricted (ie, are not *), the command will be run when | restricted (ie, are not *), the command will be run when | ||||
.Em either | .Em either | ||||
field matches the current time. | field matches the current time. | ||||
For example, | For example, | ||||
``30 4 1,15 * 5'' | ``30 4 1,15 * 5'' | ||||
Show All 34 Lines | |||||
.Sh EXAMPLE CRON FILE | .Sh EXAMPLE CRON FILE | ||||
.Bd -literal | .Bd -literal | ||||
# use /bin/sh to run commands, overriding the default set by cron | # use /bin/sh to run commands, overriding the default set by cron | ||||
SHELL=/bin/sh | SHELL=/bin/sh | ||||
# mail any output to `paul', no matter whose crontab this is | # mail any output to `paul', no matter whose crontab this is | ||||
MAILTO=paul | MAILTO=paul | ||||
# | # | ||||
# run every minute, suppress logging | |||||
* * * * * -q date | |||||
# run every minute, only send mail if ping fails | |||||
* * * * * -n ping -c 1 freebsd.org | |||||
# run five minutes after midnight, every day | # run five minutes after midnight, every day | ||||
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1 | 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 | # run at 2:15pm on the first of every month -- output mailed to paul | ||||
15 14 1 * * $HOME/bin/monthly | 15 14 1 * * $HOME/bin/monthly | ||||
# run at 10 pm on weekdays, annoy Joe | # run at 10 pm on weekdays, annoy Joe | ||||
0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?% | 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" | 23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday" | ||||
5 4 * * sun echo "run at 5 after 4 every sunday" | 5 4 * * sun echo "run at 5 after 4 every sunday" | ||||
# run at 5 minutes intervals, no matter how long it takes | # run at 5 minutes intervals, no matter how long it takes | ||||
@300 svnlite up /usr/src | @300 svnlite up /usr/src | ||||
# run every minute, suppress logging | |||||
* * * * * -q date | |||||
# run every minute, only send mail if ping fails | |||||
* * * * * -n ping -c 1 freebsd.org | |||||
.Ed | .Ed | ||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||
.Xr crontab 1 , | .Xr crontab 1 , | ||||
.Xr cron 8 | .Xr cron 8 | ||||
.Sh EXTENSIONS | .Sh EXTENSIONS | ||||
When specifying day of week, both day 0 and day 7 will be considered Sunday. | When specifying day of week, both day 0 and day 7 will be considered Sunday. | ||||
.Bx | .Bx | ||||
and | and | ||||
Show All 27 Lines | |||||
mailed to a person other than the crontab owner (SysV cannot do this), or the | mailed to a person other than the crontab owner (SysV cannot do this), or the | ||||
feature can be turned off and no mail will be sent at all (SysV cannot do this | feature can be turned off and no mail will be sent at all (SysV cannot do this | ||||
either). | either). | ||||
.Pp | .Pp | ||||
All of the | All of the | ||||
.Sq @ | .Sq @ | ||||
directives that can appear in place of the first five fields | directives that can appear in place of the first five fields | ||||
are extensions. | are extensions. | ||||
.Pp | |||||
Command processing can be modified using command options. The | |||||
.Sq -q | |||||
option suppresses logging. The | |||||
.Sq -n | |||||
option does not mail on successful run. | |||||
.Sh AUTHORS | .Sh AUTHORS | ||||
.An Paul Vixie Aq Mt paul@vix.com | .An Paul Vixie Aq Mt paul@vix.com | ||||
.Sh BUGS | .Sh BUGS | ||||
If you are in one of the 70-odd countries that observe Daylight | If you are in one of the 70-odd countries that observe Daylight | ||||
Savings Time, jobs scheduled during the rollback or advance may be | Savings Time, jobs scheduled during the rollback or advance may be | ||||
affected if | affected if | ||||
.Xr cron 8 | .Xr cron 8 | ||||
is not started with the | is not started with the | ||||
Show All 19 Lines |