1 .\" $NetBSD: crontab.5,v 1.12 2009/04/04 16:05:10 perry Exp $
3 .\"/* Copyright 1988,1990,1993,1994 by Paul Vixie
4 .\" * All rights reserved
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
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
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
12 .\" * anyone resulting from the use of this software rests entirely with the
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:
17 .\" * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
20 .\" Id: crontab.5,v 2.4 1994/01/15 20:43:43 vixie Exp
27 .Nd tables for driving cron
31 file contains instructions to the
33 daemon of the general form:
34 .Dq run this command at this time on this date .
35 Each user has their own crontab, and commands in any given crontab
36 will be executed as the user who owns the crontab.
37 Uucp and News will usually have their own crontabs, eliminating
38 the need for explicitly running
40 as part of a cron command.
42 Blank lines and leading spaces and tabs are ignored.
43 Lines whose first non-space character is a pound-sign
45 are comments, and are ignored.
46 Note that comments are not allowed on the same line as cron commands, since
47 they will be taken to be part of the command.
48 Similarly, comments are not
49 allowed on the same line as environment variable settings.
51 An active line in a crontab will be either an environment setting
53 An environment setting is of the form,
57 where the spaces around the equal-sign
59 are optional, and any subsequent non-leading spaces in
61 will be part of the value assigned to
65 string may be placed in quotes (single or double, but matching) to
66 preserve leading or trailing blanks.
69 string may also be placed in quotes (single or double, but matching)
70 to preserve leading, trailing or inner blanks.
72 Several environment variables are set up automatically by the
84 line of the crontab's owner.
88 may be overridden by settings in the crontab;
94 variable is sometimes called
96 on BSD systems... on these systems,
108 if it has any reason to send mail as a result of running commands in
113 is defined (and non-empty), mail is sent to the user so named.
117 .Pq Ev MAILTO Ns = Ns \&"" ,
118 no mail will be sent.
119 Otherwise mail is sent to the owner of the crontab.
120 This option is useful if you decide on
124 as your mailer when you install cron --
126 doesn't do aliasing, and UUCP usually doesn't read its mail.
128 In order to provide finer control over when jobs execute, users
129 can also set the environment variables
135 variable can be set to an alternate time zone in order to affect
137 Note that this only affects the scheduling of the job, not the time
138 zone that the job perceives when it is run.
142 .Pq Ev CRON_TZ Ns = Ns \&"" ,
143 jobs are scheduled with respect to the local time zone.
147 variable should indicate the number of seconds within a job's
148 scheduled time that it should still be run.
149 On a heavily loaded system, or on a system that has just been
151 jobs will sometimes start later than originally intended, and by
152 skipping non-critical jobs because of delays, system load can be
157 .Pa Ev CRON_WITHIN Ns = Ns \&""
158 or set to some non-positive value (0, a negative number, or a
159 non-numeric string), it is treated as if it was unset.
161 The format of a cron command is very much the V7 standard, with a
162 number of upward-compatible extensions.
163 Each line has five time and date fields, followed by a user name
164 if this is the system crontab file, followed by a command.
165 Commands are executed by
167 when the minute, hour, and month of year fields match the current
170 when at least one of the two day fields (day of month, or day of week)
171 match the current time (see
175 examines cron entries once every minute.
176 The time and date fields are:
177 .Bl -column -offset indent "day of month" "0-7 (0 or 7 is Sun, or use names)"
178 .It Em field Ta Em allowed values
181 .It day of month Ta 1-31
182 .It month Ta 1-12 (or names, see below)
183 .It day of week Ta 0-7 (0 or 7 is Sun, or use names)
186 A field may be an asterisk
188 which always stands for
191 Ranges of numbers are allowed.
192 Ranges are two numbers separated with a hyphen.
193 The specified range is inclusive.
198 entry specifies execution at hours 8, 9, 10, and 11.
200 A field may begin with a question mark
202 which indicates a single value randomly selected when the crontab
204 If the field contains only a question mark, the value is randomly
205 selected from the range of all possible values for the field.
206 If the question mark precedes a range, the value is randomly selected
210 specifies that a task will be performed daily between 2:00am and
211 and 5:59am at a time randomly selected when the crontab file is
213 As just one example, this feature can be used to prevent a large
214 number of hosts from contacting a server simultaneously and
215 overloading it by staggering the time at which a download script
219 A list is a set of numbers (or ranges) separated by commas.
224 Step values can be used in conjunction with ranges.
225 Following a range with
227 specifies skips of the number's value through the range.
230 can be used in the hours field to specify command execution every
231 other hour (the alternative in the V7 standard is
232 .Dq 0,2,4,6,8,10,12,14,16,18,20,22 ) .
233 Steps are also permitted after an asterisk, so if you want to say
234 .Dq every two hours ,
238 Names can also be used for the
243 Use the first three letters of the particular day or month (case
245 Ranges or lists of names are not allowed.
249 field (the rest of the line) specifies the command to be run.
250 The entire command portion of the line, up to a newline or percent
255 or by the shell specified in the
257 variable of the cronfile.
260 in the command, unless escaped with backslash
262 will be changed into newline characters, and all data after the
263 first % will be sent to the command as standard input.
266 The day of a command's execution can be specified by two fields
267 \(em day of month, and day of week.
268 If both fields are restricted (i.e., aren't *), the command will
271 field matches the current time.
274 would cause a command to be run at 4:30 am on the 1st and 15th of
275 each month, plus every Friday.
277 Instead of the first five fields, one of eight special strings may appear:
278 .Bl -column -offset indent "@annually" "Run once a month, 0 0 1 * *."
279 .It Sy string Ta Sy meaning
280 .It @reboot Ta Run once, at startup.
281 .It @yearly Ta Run once a year, Dq 0 0 1 1 * .
282 .It @annually Ta (same as @yearly)
283 .It @monthly Ta Run once a month, Dq 0 0 1 * * .
284 .It @weekly Ta Run once a week, Dq 0 0 * * 0 .
285 .It @daily Ta Run once a day, Dq 0 0 * * * .
286 .It @midnight Ta (same as @daily)
287 .It @hourly Ta Run once an hour, Dq 0 * * * * .
289 .Ss EXAMPLE CRON FILE
291 # use /bin/sh to run commands, no matter what /etc/passwd says
293 # mail any output to `paul', no matter whose crontab this is
296 # run five minutes after midnight, every day
297 5 0 * * * $HOME/bin/daily.job \*[Gt]\*[Gt] $HOME/tmp/out 2\*[Gt]\*[Am]1
298 # run at 2:15pm on the first of every month -- output mailed to paul
299 15 14 1 * * $HOME/bin/monthly
300 # run at 10 pm on weekdays, annoy Joe
301 0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
302 23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
303 5 4 * * sun echo "run at 5 after 4 every sunday"
304 ? ?2-4 1,15 * * echo "random between 2am-4:59am on the 1st and 15th"
310 When specifying day of week, both day 0 and day 7 will be considered
312 BSD and ATT seem to disagree about this.
314 Lists and ranges are allowed to co-exist in the same field.
316 would be rejected by ATT or BSD cron -- they want to see
329 Names of months or days of the week can be specified by name.
331 Environment variables can be set in the crontab.
332 In BSD or ATT, the environment handed to child processes is basically
336 Command output is mailed to the crontab owner (BSD can't do this),
337 can be mailed to a person other than the crontab owner (SysV can't
338 do this), or the feature can be turned off and no mail will be sent
339 at all (SysV can't do this either).
343 commands that can appear in place of the first five fields are
346 .An Paul Vixie Aq paul@vix.com