xref: /386bsd/usr/share/man/cat1/crontab.0 (revision a2142627)
1
2
3
4CRONTAB(5)                     1990                    CRONTAB(5)
5
6
7NNAAMMEE
8       crontab - tables for driving cron
9
10DDEESSCCRRIIPPTTIIOONN
11       A  _c_r_o_n_t_a_b  file  contains  instructions  to  the _c_r_o_n_d(8)
12       daemon of the general form: ``run  this  command  at  this
13       time on this date''.  Each user has their own crontab, and
14       commands in any given crontab will be executed as the user
15       who  owns  the  crontab.   Uucp and News will usually have
16       their own crontabs, eliminating the  need  for  explicitly
17       running _s_u(1) as part of a cron command.
18
19       Blank  lines  and  leading  spaces  and  tabs are ignored.
20       Lines whose first non-space character is a pound-sign  (#)
21       are comments, and are ignored.  Note that comments are not
22       allowed on the same line as cron commands, since they will
23       be  taken  to be part of the command.  Similarly, comments
24       are not allowed on the same line as  environment  variable
25       settings.
26
27       An  active line in a crontab will be either an environment
28       setting or a cron command.  An environment setting  is  of
29       the form,
30
31           name = value
32
33       where  the  spaces around the equal-sign (=) are optional,
34       and any subsequent non-leading spaces  in  _v_a_l_u_e  will  be
35       part  of the value assigned to _n_a_m_e.  The _v_a_l_u_e string may
36       be placed in quotes (single or double,  but  matching)  to
37       preserve leading or trailing blanks.
38
39       Several  environment variables are set up automatically by
40       the _c_r_o_n_d(8) daemon  from  the  /etc/passwd  line  of  the
41       crontab's  owner:  USER,  HOME, and SHELL.  HOME and SHELL
42       may be overridden by settings in  the  crontab;  USER  may
43       not.
44
45       (Note:  for  UUCP,  always  set SHELL=/bin/sh, or _c_r_o_n_d(8)
46       will  cheerfully  try  to  execute  your  commands   using
47       /usr/lib/uucp/uucico.)
48
49       (Another  note:  the  USER  variable  is  sometimes called
50       LOGNAME or worse on System V... on these systems,  LOGNAME
51       will be set rather than USER.)
52
53       In  addition  to USER, HOME, and SHELL, _c_r_o_n_d(8) will look
54       at MAILTO if it has any reason to send mail as a result of
55       running  commands  in  ``this''  crontab.   If  MAILTO  is
56       defined (and non-empty), mail  is  sent  to  the  user  so
57       named.   If  MAILTO  is  defined but empty (MAILTO=""), no
58       mail will be sent.  Otherwise mail is sent to the owner of
59       the  crontab.   This  option  is  useful  if you decide on
60       /bin/mail instead of /usr/lib/sendmail as your mailer when
61
62
63
64January                         15                              1
65
66
67
68
69
70CRONTAB(5)                     1990                    CRONTAB(5)
71
72
73       you  install  cron  --  /bin/mail doesn't do aliasing, and
74       UUCP usually doesn't read its mail.
75
76       The format of a cron command is very much the V7 standard,
77       with  a number of upward-compatible extensions.  Each line
78       has five time and date  fields,  followed  by  a  command.
79       Commands  are  executed by _c_r_o_n_d(8) when the minute, hour,
80       and month of year fields match the current time, _a_n_d  when
81       at  least  one of the two day fields (day of month, or day
82       of week) match the  current  time  (see  ``Note''  below).
83       _c_r_o_n_d(8)  examines  cron  entries  once every minute.  The
84       time and date fields are:
85
86              field          allowed values
87              -----          --------------
88              minute         0-59
89              hour           0-23
90              day of month   0-31
91              month          0-12 (or names, see below)
92              day of week    0-7 (0 or 7 is Sun, or use names)
93
94       A field may be an asterisk (*), which always  matches  the
95       current time.
96
97       Ranges  of  numbers  are  allowed.  Ranges are two numbers
98       separated  with  a  hyphen.   The   specified   range   is
99       inclusive.   For  example,  8-11  for  an  ``hours'' entry
100       specifies execution at hours 8, 9, 10 and 11.
101
102       Lists are allowed.  A list is a set of numbers (or ranges)
103       separated by commas.  Examples: ``1,2,5,9'', ``0-4,8-12''.
104
105       Step values  can  be  used  in  conjunction  with  ranges.
106       Following  a  range  with ``/<number>'' specifies skips of
107       the  number's  value  through  the  range.   For  example,
108       ``0-23/2''  can  be  used  in  the  hours field to specify
109       command execution every other hour (the alternative in the
110       V7 standard is ``0,2,4,6,8,10,12,14,16,18,20,22'').
111
112       Names  can  also  be  used  for the ``month'' and ``day of
113       week''  fields.   Use  the  first  three  letters  of  the
114       particular  day or month (case doesn't matter).  Ranges or
115       lists of names are not allowed.
116
117       The ``sixth'' field (the rest of the line)  specifies  the
118       command  to  be  run.   The  entire command portion of the
119       line, up to a newline or % character, will be executed  by
120       the  user's  login  shell or by the shell specified in the
121       SHELL variable of the cronfile.  Percent-signs (%) in  the
122       command,  unless  escaped  with  backslash  (\),  will  be
123       changed into newline characters, and all  data  after  the
124       first % will be sent to the command as standard input.
125
126       Note: The day of a command's execution can be specified by
127
128
129
130January                         15                              2
131
132
133
134
135
136CRONTAB(5)                     1990                    CRONTAB(5)
137
138
139       two fields - day of month,  and  day  of  week.   If  both
140       fields  are restricted (ie, aren't *), the command will be
141       run when _e_i_t_h_e_r  field  matches  the  current  time.   For
142       example,
143       ``30  4 1,15 * 5'' would cause a command to be run at 4:30
144       am on the 1st and 15th of each month, plus every Friday.
145
146EEXXAAMMPPLLEE CCRROONN FFIILLEE
147       # use /bin/sh to run commands, no matter what /etc/passwd says
148       SHELL=/bin/sh
149       # mail any output to `paul', no matter whose crontab this is
150       MAILTO=paul
151       #
152       # run five minutes after midnight, every day
153       5 0 * * *       $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
154       # run at 2:15pm on the first of every month -- output mailed to paul
155       15 14 1 * *     $HOME/bin/monthly
156       # run at 10 pm on weekdays, annoy Joe
157       0 22 * * 1-5   mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
158       23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
159       5 4 * * sun     echo "run at 5 after 4 every sunday"
160
161SSEEEE AALLSSOO
162       crond(8), crontab(1)
163
164EEXXTTEENNSSIIOONNSS
165       When specifying day of week, both day 0 and day 7 will  be
166       considered  Sunday.   BSD  and  ATT seem to disagree about
167       this.
168
169       Lists and ranges are  allowed  to  co-exist  in  the  same
170       field.   "1-3,7-9" would be rejected by ATT or BSD cron --
171       they want to see "1-3" or "7,8,9" ONLY.
172
173       Ranges can include "steps", so  "1-9/2"  is  the  same  as
174       "1,3,5,7,9".
175
176       Names  of  months  or days of the week can be specified by
177       name.
178
179       Environment variables can be set in the crontab.   In  BSD
180       or  ATT,  the  environment  handed  to  child processes is
181       basically the one from /etc/rc.
182
183       Command output is mailed to the crontab owner  (BSD  can't
184       do this), can be mailed to a person other than the crontab
185       owner (SysV can't do this), or the feature can  be  turned
186       off  and  no  mail will be sent at all (SysV can't do this
187       either).
188
189AAUUTTHHOORR
190       Paul Vixie, paul@vixie.sf.ca.us
191
192
193
194
195
196January                         15                              3
197
198
199