Sat Apr 4 17:30:00 2009 UTC ()
Convert to mdoc. Bump date for previous.


(wiz)
diff -r1.12 -r1.13 src/usr.sbin/cron/crontab.5

cvs diff -r1.12 -r1.13 src/usr.sbin/cron/Attic/crontab.5 (expand / switch to unified diff)

--- src/usr.sbin/cron/Attic/crontab.5 2009/04/04 16:05:10 1.12
+++ src/usr.sbin/cron/Attic/crontab.5 2009/04/04 17:29:59 1.13
@@ -1,256 +1,346 @@ @@ -1,256 +1,346 @@
1.\" $NetBSD: crontab.5,v 1.12 2009/04/04 16:05:10 perry Exp $ 1.\" $NetBSD: crontab.5,v 1.13 2009/04/04 17:29:59 wiz Exp $
2.\" 2.\"
3.\"/* Copyright 1988,1990,1993,1994 by Paul Vixie 3.\"/* Copyright 1988,1990,1993,1994 by Paul Vixie
4.\" * All rights reserved 4.\" * All rights reserved
5.\" * 5.\" *
6.\" * Distribute freely, except: don't remove my name from the source or 6.\" * Distribute freely, except: don't remove my name from the source or
7.\" * documentation (don't take credit for my work), mark your changes (don't 7.\" * documentation (don't take credit for my work), mark your changes (don't
8.\" * get me blamed for your possible bugs), don't alter or remove this 8.\" * get me blamed for your possible bugs), don't alter or remove this
9.\" * notice. May be sold if buildable source is provided to buyer. No 9.\" * notice. May be sold if buildable source is provided to buyer. No
10.\" * warrantee of any kind, express or implied, is included with this 10.\" * warrantee of any kind, express or implied, is included with this
11.\" * software; use at your own risk, responsibility for damages (if any) to 11.\" * software; use at your own risk, responsibility for damages (if any) to
12.\" * anyone resulting from the use of this software rests entirely with the 12.\" * anyone resulting from the use of this software rests entirely with the
13.\" * user. 13.\" * user.
14.\" * 14.\" *
15.\" * Send bug reports, bug fixes, enhancements, requests, flames, etc., and 15.\" * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
16.\" * I'll try to keep a version up to date. I can be reached as follows: 16.\" * I'll try to keep a version up to date. I can be reached as follows:
17.\" * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul 17.\" * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
18.\" */ 18.\" */
19.\" 19.\"
20.\" Id: crontab.5,v 2.4 1994/01/15 20:43:43 vixie Exp 20.\" Id: crontab.5,v 2.4 1994/01/15 20:43:43 vixie Exp
21.\" 21.\"
22.TH CRONTAB 5 "24 January 1994" 22.Dd April 4, 2009
23.UC 4 23.Dt CRONTAB 5
24.SH NAME 24.Os
25crontab \- tables for driving cron 25.Sh NAME
26.SH DESCRIPTION 26.Nm crontab
 27.Nd tables for driving cron
 28.Sh DESCRIPTION
27A 29A
28.I crontab 30.Nm
29file contains instructions to the 31file contains instructions to the
30.IR cron (8) 32.Xr cron 8
31daemon of the general form: ``run this command at this time on this date''. 33daemon of the general form:
32Each user has their own crontab, and commands in any given crontab will be 34.Dq run this command at this time on this date .
33executed as the user who owns the crontab. Uucp and News will usually have 35Each user has their own crontab, and commands in any given crontab
34their own crontabs, eliminating the need for explicitly running 36will be executed as the user who owns the crontab.
35.IR su (1) 37Uucp and News will usually have their own crontabs, eliminating
 38the need for explicitly running
 39.Xr su 1
36as part of a cron command. 40as part of a cron command.
37.PP 41.Pp
38Blank lines and leading spaces and tabs are ignored. Lines whose first 42Blank lines and leading spaces and tabs are ignored.
39non-space character is a pound-sign (#) are comments, and are ignored. 43Lines whose first non-space character is a pound-sign
 44.Pq Sq #
 45are comments, and are ignored.
40Note that comments are not allowed on the same line as cron commands, since 46Note that comments are not allowed on the same line as cron commands, since
41they will be taken to be part of the command. Similarly, comments are not 47they will be taken to be part of the command.
 48Similarly, comments are not
42allowed on the same line as environment variable settings. 49allowed on the same line as environment variable settings.
43.PP 50.Pp
44An active line in a crontab will be either an environment setting or a cron 51An active line in a crontab will be either an environment setting
45command. An environment setting is of the form, 52or a cron command.
46.PP 53An environment setting is of the form,
 54.Bd -literal
47 name = value 55 name = value
48.PP 56.Ed
49where the spaces around the equal-sign (=) are optional, and any subsequent 57where the spaces around the equal-sign
50non-leading spaces in 58.Pq Sq =
51.I value 59are optional, and any subsequent non-leading spaces in
 60.Ar value
52will be part of the value assigned to 61will be part of the value assigned to
53.IR name . 62.Ar name .
54The 63The
55.I value 64.Ar value
56string may be placed in quotes (single or double, but matching) to preserve 65string may be placed in quotes (single or double, but matching) to
57leading or trailing blanks. The 66preserve leading or trailing blanks.
58.I name 67The
59string may also be placed in quotes (single or double, but matching) to preserve 68.Ar name
60leading, trailing or inner blanks. 69string may also be placed in quotes (single or double, but matching)
61.PP 70to preserve leading, trailing or inner blanks.
62Several environment variables are set up 71.Pp
63automatically by the 72Several environment variables are set up automatically by the
64.IR cron (8) 73.Xr cron 8
65daemon. 74daemon.
66SHELL is set to /bin/sh, and LOGNAME and HOME are set from the /etc/passwd 75.Ev SHELL
 76is set to
 77.Pa /bin/sh ,
 78and
 79.Ev LOGNAME
 80and
 81.Ev HOME
 82are set from the
 83.Pa /etc/passwd
67line of the crontab's owner. 84line of the crontab's owner.
68HOME and SHELL may be overridden by settings in the crontab; LOGNAME may not. 85.Ev HOME
69.PP 86and
70(Another note: the LOGNAME variable is sometimes called USER on BSD systems... 87.Ev SHELL
71on these systems, USER will be set also.) 88may be overridden by settings in the crontab;
72.PP 89.Ev LOGNAME
73In addition to LOGNAME, HOME, and SHELL, 90may not.
74.IR cron (8) 91.Pp
75will look at MAILTO if it has any reason to send mail as a result of running 92(Another note: the
76commands in ``this'' crontab. If MAILTO is defined (and non-empty), mail is 93.Ev LOGNAME
77sent to the user so named. If MAILTO is defined but empty (MAILTO=""), no 94variable is sometimes called
78mail will be sent. Otherwise mail is sent to the owner of the crontab. This 95.Ev USER
79option is useful if you decide on /bin/mail instead of /usr/lib/sendmail as 96on BSD systems... on these systems,
80your mailer when you install cron -- /bin/mail doesn't do aliasing, and UUCP 97.Ev USER
81usually doesn't read its mail. 98will be set also.)
82.PP 99.Pp
 100In addition to
 101.Ev LOGNAME ,
 102.Ev HOME ,
 103and
 104.Ev SHELL ,
 105.Xr cron 8
 106will look at
 107.Ev MAILTO
 108if it has any reason to send mail as a result of running commands in
 109.Dq this
 110crontab.
 111If
 112.Ev MAILTO
 113is defined (and non-empty), mail is sent to the user so named.
 114If
 115.Ev MAILTO
 116is defined but empty
 117.Pq Ev MAILTO Ns = Ns \&"" ,
 118no mail will be sent.
 119Otherwise mail is sent to the owner of the crontab.
 120This option is useful if you decide on
 121.Xr mail 1
 122instead of
 123.Xr sendmail 1
 124as your mailer when you install cron --
 125.Xr mail 1
 126doesn't do aliasing, and UUCP usually doesn't read its mail.
 127.Pp
83In order to provide finer control over when jobs execute, users 128In order to provide finer control over when jobs execute, users
84can also set the environment variables CRON_TZ and CRON_WITHIN. 129can also set the environment variables
85The CRON_TZ variable can be set to an alternate time zone in order 130.Ev CRON_TZ
86to affect when the job is run. Note that this only affects the 131and
87scheduling of the job, not the time zone that the job perceives 132.Ev CRON_WITHIN .
88when it is run. If CRON_TZ is defined but empty (CRON_TZ=""), jobs 133The
89are scheduled with respect to the local time zone. 134.Ev CRON_TZ
90.PP 135variable can be set to an alternate time zone in order to affect
91The CRON_WITHIN variable should indicate the number of seconds 136when the job is run.
92within a job's scheduled time that it should still be run. On a 137Note that this only affects the scheduling of the job, not the time
93heavily loaded system, or on a system that has just been "woken 138zone that the job perceives when it is run.
94up", jobs will sometimes start later than originally intended, and 139If
95by skipping non-critical jobs because of delays, system load can 140.Ev CRON_TZ
96be lightened. If CRON_WITHIN is defined but empty (CRON_WITHIN="") or 141is defined but empty
97set to some non-positive value (0, a negative number, or a non-numeric 142.Pq Ev CRON_TZ Ns = Ns \&"" ,
98string), it is treated as if it was unset. 143jobs are scheduled with respect to the local time zone.
99.PP 144.Pp
100The format of a cron command is very much the V7 standard, with a number of 145The
101upward-compatible extensions. Each line has five time and date fields, 146.Ev CRON_WITHIN
102followed by a user name if this is the system crontab file, 147variable should indicate the number of seconds within a job's
103followed by a command. Commands are executed by 148scheduled time that it should still be run.
104.IR cron (8) 149On a heavily loaded system, or on a system that has just been
105when the minute, hour, and month of year fields match the current time, 150.Dq woken up ,
106.I and 151jobs will sometimes start later than originally intended, and by
 152skipping non-critical jobs because of delays, system load can be
 153lightened.
 154If
 155.Ev CRON_WITHIN
 156is defined but empty
 157.Pa Ev CRON_WITHIN Ns = Ns \&""
 158or set to some non-positive value (0, a negative number, or a
 159non-numeric string), it is treated as if it was unset.
 160.Pp
 161The format of a cron command is very much the V7 standard, with a
 162number of upward-compatible extensions.
 163Each line has five time and date fields, followed by a user name
 164if this is the system crontab file, followed by a command.
 165Commands are executed by
 166.Xr cron 8
 167when the minute, hour, and month of year fields match the current
 168time,
 169.Em and
107when at least one of the two day fields (day of month, or day of week) 170when at least one of the two day fields (day of month, or day of week)
108match the current time (see ``Note'' below). 171match the current time (see
109.IR cron (8) 172.Dq Note
 173below).
 174.Xr cron 8
110examines cron entries once every minute. 175examines cron entries once every minute.
111The time and date fields are: 176The time and date fields are:
112.IP 177.Bl -column -offset indent "day of month" "0-7 (0 or 7 is Sun, or use names)"
113.ta 1.5i 178.It Em field Ta Em allowed values
114field allowed values 179.It minute Ta 0-59
115.br 180.It hour Ta 0-23
116----- -------------- 181.It day of month Ta 1-31
117.br 182.It month Ta 1-12 (or names, see below)
118minute 0-59 183.It day of week Ta 0-7 (0 or 7 is Sun, or use names)
119.br 184.El
120hour 0-23 185.Pp
121.br 186A field may be an asterisk
122.\" changed from 0-31 to 1-31: mouse, 1997-07-13 187.Pq Sq * ,
123day of month 1-31 188which always stands for
124.br 189.Dq first\-last .
125.\" changed from 0-12 to 1-12: mouse, 1997-07-13 190.Pp
126month 1-12 (or names, see below) 191Ranges of numbers are allowed.
127.br 192Ranges are two numbers separated with a hyphen.
128day of week 0-7 (0 or 7 is Sun, or use names) 193The specified range is inclusive.
129.br 194For example,
130.PP 195.Dq 8-11
131A field may be an asterisk (*), which always stands for ``first\-last''. 196for an
132.PP 197.Dq hours
133Ranges of numbers are allowed. Ranges are two numbers separated 198entry specifies execution at hours 8, 9, 10, and 11.
134with a hyphen. The specified range is inclusive. For example, 199.Pp
1358-11 for an ``hours'' entry specifies execution at hours 8, 9, 10 200A field may begin with a question mark
136and 11. 201.Pq Sq ? ,
137.PP 202which indicates a single value randomly selected when the crontab
138A field may begin with a question mark (?), which indicates a 203file is read.
139single value randomly selected when the crontab file is read. 
140If the field contains only a question mark, the value is randomly 204If the field contains only a question mark, the value is randomly
141selected from the range of all possible values for the field. 205selected from the range of all possible values for the field.
142If the question mark precedes a range, the value is randomly selected 206If the question mark precedes a range, the value is randomly selected
143from the range. 207from the range.
144For example, ``? ?2-5 * * *'' specifies that a task will be performed 208For example,
145daily between 2:00am and and 5:59am at a time randomly selected when 209.Dq ? ?2-5 * * *
146the crontab file is first read. 210specifies that a task will be performed daily between 2:00am and
 211and 5:59am at a time randomly selected when the crontab file is
 212first read.
147As just one example, this feature can be used to prevent a large 213As just one example, this feature can be used to prevent a large
148number of hosts from contacting a server simultaneously and 214number of hosts from contacting a server simultaneously and
149overloading it by staggering the time at which a download script is 215overloading it by staggering the time at which a download script
150executed. 216is executed.
151.PP 217.Pp
152Lists are allowed. A list is a set of numbers (or ranges) 218Lists are allowed.
153separated by commas. Examples: ``1,2,5,9'', ``0-4,8-12''. 219A list is a set of numbers (or ranges) separated by commas.
154.PP 220Examples:
155Step values can be used in conjunction with ranges. Following 221.Dq 1,2,5,9 ,
156a range with ``/\*[Lt]number\*[Gt]'' specifies skips of the number's value 222.Dq 0-4,8-12 .
157through the range. For example, ``0-23/2'' can be used in the hours 223.Pp
158field to specify command execution every other hour (the alternative 224Step values can be used in conjunction with ranges.
159in the V7 standard is ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are 225Following a range with
160also permitted after an asterisk, so if you want to say ``every two 226.Dq / Ns Aq number
161hours'', just use ``*/2''. 227specifies skips of the number's value through the range.
162.PP 228For example,
163Names can also be used for the ``month'' and ``day of week'' 229.Dq 0-23/2
164fields. Use the first three letters of the particular 230can be used in the hours field to specify command execution every
165day or month (case doesn't matter). Ranges or 231other hour (the alternative in the V7 standard is
166lists of names are not allowed. 232.Dq 0,2,4,6,8,10,12,14,16,18,20,22 ) .
167.PP 233Steps are also permitted after an asterisk, so if you want to say
168The ``sixth'' field (the rest of the line) specifies the command to be 234.Dq every two hours ,
169run. 235just use
170The entire command portion of the line, up to a newline or % 236.Dq */2 .
171character, will be executed by /bin/sh or by the shell 237.Pp
172specified in the SHELL variable of the cronfile. 238Names can also be used for the
173Percent-signs (%) in the command, unless escaped with backslash 239.Dq month
174(\\), will be changed into newline characters, and all data 240and
175after the first % will be sent to the command as standard 241.Dq day of week
176input. 242fields.
177.PP 243Use the first three letters of the particular day or month (case
178Note: The day of a command's execution can be specified by two 244doesn't matter).
179fields \(em day of month, and day of week. If both fields are 245Ranges or lists of names are not allowed.
180restricted (ie, aren't *), the command will be run when 246.Pp
181.I either 247The
182field matches the current time. For example, 248.Dq sixth
183.br 249field (the rest of the line) specifies the command to be run.
184``30 4 1,15 * 5'' 250The entire command portion of the line, up to a newline or percent
185would cause a command to be run at 4:30 am on the 1st and 15th of each 251signs
186month, plus every Friday. 252.Pq Sq % ,
187.\" Everything from here to .SH EXAMPLE CRON FILE added: mouse, 1997-07-13 253will be executed by
188.PP 254.Xr sh 1
 255or by the shell specified in the
 256.Ev SHELL
 257variable of the cronfile.
 258Percent signs
 259.Pq Sq %
 260in the command, unless escaped with backslash
 261.Pq Sq \e ,
 262will be changed into newline characters, and all data after the
 263first % will be sent to the command as standard input.
 264.Pp
 265.Em Note :
 266The day of a command's execution can be specified by two fields
 267\(em day of month, and day of week.
 268If both fields are restricted (i.e., aren't *), the command will
 269be run when
 270.Em either
 271field matches the current time.
 272For example,
 273.Dq 30 4 1,15 * 5
 274would cause a command to be run at 4:30 am on the 1st and 15th of
 275each month, plus every Friday.
 276.Pp
189Instead of the first five fields, one of eight special strings may appear: 277Instead of the first five fields, one of eight special strings may appear:
190.IP 278.Bl -column -offset indent "@annually" "Run once a month, 0 0 1 * *."
191.ta 1.5i 279.It Sy string Ta Sy meaning
192string meaning 280.It @reboot Ta Run once, at startup.
193.br 281.It @yearly Ta Run once a year, Dq 0 0 1 1 * .
194------ ------- 282.It @annually Ta (same as @yearly)
195.br 283.It @monthly Ta Run once a month, Dq 0 0 1 * * .
196@reboot Run once, at startup. 284.It @weekly Ta Run once a week, Dq 0 0 * * 0 .
197.br 285.It @daily Ta Run once a day, Dq 0 0 * * * .
198@yearly Run once a year, "0 0 1 1 *". 286.It @midnight Ta (same as @daily)
199.br 287.It @hourly Ta Run once an hour, Dq 0 * * * * .
200@annually (same as @yearly) 288.El
201.br 289.Ss EXAMPLE CRON FILE
202@monthly Run once a month, "0 0 1 * *". 290.Bd -literal
203.br 
204@weekly Run once a week, "0 0 * * 0". 
205.br 
206@daily Run once a day, "0 0 * * *". 
207.br 
208@midnight (same as @daily) 
209.br 
210@hourly Run once an hour, "0 * * * *". 
211.br 
212.SH EXAMPLE CRON FILE 
213.nf 
214 
215# use /bin/sh to run commands, no matter what /etc/passwd says 291# use /bin/sh to run commands, no matter what /etc/passwd says
216SHELL=/bin/sh 292SHELL=/bin/sh
217# mail any output to `paul', no matter whose crontab this is 293# mail any output to `paul', no matter whose crontab this is
218MAILTO=paul 294MAILTO=paul
219# 295#
220# run five minutes after midnight, every day 296# run five minutes after midnight, every day
2215 0 * * * $HOME/bin/daily.job \*[Gt]\*[Gt] $HOME/tmp/out 2\*[Gt]\*[Am]1 2975 0 * * * $HOME/bin/daily.job \*[Gt]\*[Gt] $HOME/tmp/out 2\*[Gt]\*[Am]1
222# run at 2:15pm on the first of every month -- output mailed to paul 298# run at 2:15pm on the first of every month -- output mailed to paul
22315 14 1 * * $HOME/bin/monthly 29915 14 1 * * $HOME/bin/monthly
224# run at 10 pm on weekdays, annoy Joe 300# run at 10 pm on weekdays, annoy Joe
2250 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?% 3010 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
22623 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday" 30223 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
2275 4 * * sun echo "run at 5 after 4 every sunday" 3035 4 * * sun echo "run at 5 after 4 every sunday"
228? ?2-4 1,15 * * echo "random between 2am-4:59am on the 1st and 15th" 304? ?2-4 1,15 * * echo "random between 2am-4:59am on the 1st and 15th"
229.fi 305.Ed
230.SH SEE ALSO 306.Sh SEE ALSO
231cron(8), crontab(1) 307.Xr crontab 1 ,
232.SH EXTENSIONS 308.Xr cron 8
233When specifying day of week, both day 0 and day 7 will be considered Sunday. 309.Sh STANDARDS
 310When specifying day of week, both day 0 and day 7 will be considered
 311Sunday.
234BSD and ATT seem to disagree about this. 312BSD and ATT seem to disagree about this.
235.PP 313.Pp
236Lists and ranges are allowed to co-exist in the same field. "1-3,7-9" would 314Lists and ranges are allowed to co-exist in the same field.
237be rejected by ATT or BSD cron -- they want to see "1-3" or "7,8,9" ONLY. 315.Dq 1-3,7-9
238.PP 316would be rejected by ATT or BSD cron -- they want to see
239Ranges can include "steps", so "1-9/2" is the same as "1,3,5,7,9". 317.Dq 1-3
240.PP 318or
 319.Dq 7,8,9
 320ONLY.
 321.Pp
 322Ranges can include
 323.Dq steps ,
 324so
 325.Dq 1-9/2
 326is the same as
 327.Dq 1,3,5,7,9 .
 328.Pp
241Names of months or days of the week can be specified by name. 329Names of months or days of the week can be specified by name.
242.PP 330.Pp
243Environment variables can be set in the crontab. In BSD or ATT, the 331Environment variables can be set in the crontab.
244environment handed to child processes is basically the one from /etc/rc. 332In BSD or ATT, the environment handed to child processes is basically
245.PP 333the one from
246Command output is mailed to the crontab owner (BSD can't do this), can be 334.Pa /etc/rc .
247mailed to a person other than the crontab owner (SysV can't do this), or the 335.Pp
248feature can be turned off and no mail will be sent at all (SysV can't do this 336Command output is mailed to the crontab owner (BSD can't do this),
249either). 337can be mailed to a person other than the crontab owner (SysV can't
250.\" This next paragraph added: mouse, 1997-07-13 338do this), or the feature can be turned off and no mail will be sent
251.PP 339at all (SysV can't do this either).
252All of the `@' commands that can appear in place of the first five fields 340.Pp
253are extensions. 341All of the
254.SH AUTHOR 342.Sq @
255.nf 343commands that can appear in place of the first five fields are
256Paul Vixie \*[Lt]paul@vix.com\*[Gt] 344extensions.
 345.Sh AUTHORS
 346.An Paul Vixie Aq paul@vix.com