1ANACRONTAB(5)                Cronie Users' Manual                ANACRONTAB(5)
2
3
4

NAME

6       crontab - tables for driving cron (ISC Cron V4.1)
7

DESCRIPTION

9       A  crontab file contains instructions to the cron(8) daemon of the gen‐
10       eral form: "run this command at this time on this date".  Each user has
11       their  own  crontab, and commands in any given crontab will be executed
12       as the user who owns the crontab.  Uucp  and  News  will  usually  have
13       their  own  crontabs, eliminating the need for explicitly running su(1)
14       as part of a cron command.
15
16       Blank lines and leading spaces and tabs are ignored.  Lines whose first
17       non-space  character is a pound-sign (#) are comments, and are ignored.
18       Note that comments are not allowed on the same line as  cron  commands,
19       since  they  will  be taken to be part of the command.  Similarly, com‐
20       ments are not allowed on the same line  as  environment  variable  set‐
21       tings.
22
23       An  active line in a crontab will be either an environment setting or a
24       cron command.  An environment setting is of the form,
25
26           name = value
27
28       where the spaces around the equal-sign (=) are optional, and any subse‐
29       quent non-leading spaces in value will be part of the value assigned to
30       name.  The value string may be placed in quotes (single or double,  but
31       matching) to preserve leading or trailing blanks.
32
33       Several  environment  variables are set up automatically by the cron(8)
34       daemon.  SHELL is set to /bin/sh, and LOGNAME and HOME are set from the
35       /etc/passwd  line  of the crontab´s owner.  HOME and SHELL may be over‐
36       ridden by settings in the crontab; LOGNAME may not.
37
38       (Another note: the LOGNAME variable is sometimes  called  USER  on  BSD
39       systems...  on these systems, USER will be set also.)
40
41       In addition to LOGNAME, HOME, and SHELL, cron(8) will look at MAILTO if
42       it has any reason to send mail as  a  result  of  running  commands  in
43       "this"  crontab.  If MAILTO is defined (and non-empty), mail is sent to
44       the user so named.  If MAILTO is defined but empty (MAILTO=""), no mail
45       will  be  sent.   Otherwise  mail  is sent to the owner of the crontab.
46       This  option  is  useful  if  you  decide  on  /bin/mail   instead   of
47       /usr/lib/sendmail  as  your  mailer  when you install cron -- /bin/mail
48       doesn´t do aliasing, and UUCP usually doesn´t read its mail.  If  MAIL‐
49       FROM is defined (and non-empty), it will be used as the envelope sender
50       address, otherwise, ``root'' will be used.
51
52       By default, cron will send mail using the mail  'Content-Type:'  header
53       of  'text/plain'  with  the  'charset='  parameter set to the charmap /
54       codeset of the locale in which crond(8) is started up - ie. either  the
55       default system locale, if no LC_* environment variables are set, or the
56       locale specified by the LC_*  environment  variables  (see  locale(7)).
57       You can use different character encodings for mailed cron job output by
58       setting the CONTENT_TYPE  and  CONTENT_TRANSFER_ENCODING  variables  in
59       crontabs, to the correct values of the mail headers of those names.
60
61       The  CRON_TZ  specifies the time zone specific for the cron table. User
62       type into the chosen table times in the  time  of  the  specified  time
63       zone.  The  time  into  log is taken from local time zone, where is the
64       daemon running.
65
66       The MLS_LEVEL environment variable provides support for  multiple  per-
67       job  SELinux  security  contexts in the same crontab.  By default, cron
68       jobs execute with the default SELinux security context of the user that
69       created  the  crontab  file.   When  using multiple security levels and
70       roles, this may not be sufficient, because the same user may be running
71       in  a  different role or at a different security level.  For more about
72       roles and SELinux MLS/MCS see  selinux(8)  and  undermentioned  crontab
73       example.   You can set MLS_LEVEL to the SELinux security context string
74       specifying the SELinux security context in which you want  the  job  to
75       run,  and  crond will set the execution context of the or jobs to which
76       the  setting  applies  to  the  specified  context.    See   also   the
77       crontab(1) -s option.
78
79       The RANDOM_DELAY variable allows delaying job startups by random amount
80       of minutes with upper limit specified by the variable. The random scal‐
81       ing  factor  is determined during the cron daemon startup so it remains
82       constant for the whole run time of the daemon.
83
84       If the CRON_CORRECT_MAIL_HEADER environment variable is present regard‐
85       less of its value, it will make crond to send e-mails with RFC2822 com‐
86       pliant From field. (Red Hat Enterprise Linux 6 only)
87
88       The format of a cron command is very much the V7 standard, with a  num‐
89       ber  of upward-compatible extensions.  Each line has five time and date
90       fields, followed by a user name if this is  the  system  crontab  file,
91       followed  by  a  command.   Commands  are  executed by cron(8) when the
92       minute, hour, and month of year fields match the current time,  and  at
93       least  one  of  the two day fields (day of month, or day of week) match
94       the current time (see "Note" below).  Note that this  means  that  non-
95       existent times, such as "missing hours" during daylight savings conver‐
96       sion, will never match, causing  jobs  scheduled  during  the  "missing
97       times"  not  to  be  run.   Similarly,  times that occur more than once
98       (again, during daylight savings conversion) will cause matching jobs to
99       be run twice.
100
101       cron(8) examines cron entries once every minute.
102
103       The time and date fields are:
104
105              field          allowed values
106              -----          --------------
107              minute         0-59
108              hour           0-23
109              day of month   1-31
110              month          1-12 (or names, see below)
111              day of week    0-7 (0 or 7 is Sun, or use names)
112
113       A field may be an asterisk (*), which always stands for "first-last".
114
115       Ranges of numbers are allowed.  Ranges are two numbers separated with a
116       hyphen.  The specified range is inclusive.  For example,  8-11  for  an
117       "hours" entry specifies execution at hours 8, 9, 10 and 11.
118
119       Lists are allowed.  A list is a set of numbers (or ranges) separated by
120       commas.  Examples: "1,2,5,9", "0-4,8-12".
121
122       Step values can be used in conjunction with ranges.  Following a  range
123       with  "<number>"  specifies  skips  of  the  number's value through the
124       range.  For example, "0-23/2" can be used in the hours field to specify
125       command  execution every other hour (the alternative in the V7 standard
126       is "0,2,4,6,8,10,12,14,16,18,20,22").  Steps are also  permitted  after
127       an asterisk, so if you want to say "every two hours", just use "*/2".
128
129       Names  can  also be used for the "month" and "day of week" fields.  Use
130       the first three letters of the particular day or  month  (case  doesn't
131       matter).  Ranges or lists of names are not allowed.
132
133       The  "sixth"  field  (the rest of the line) specifies the command to be
134       run.  The entire command portion of the line, up  to  a  newline  or  %
135       character, will be executed by /bin/sh or by the shell specified in the
136       SHELL variable of the cronfile.   Percent-signs  (%)  in  the  command,
137       unless escaped with backslash (\), will be changed into newline charac‐
138       ters, and all data after the first % will be sent  to  the  command  as
139       standard input.
140
141       Note: The day of a command's execution can be specified by two fields —
142       day of month, and day of week.  If  both  fields  are  restricted  (ie,
143       aren't  *),  the command will be run when either field matches the cur‐
144       rent time.  For example,
145       "30 4 1,15 * 5" would cause a command to be run at 4:30 am on  the  1st
146       and 15th of each month, plus every Friday.
147

EXAMPLE CRON FILE

149       # use /bin/sh to run commands, no matter what /etc/passwd says
150       SHELL=/bin/sh
151       # mail any output to `paul', no matter whose crontab this is
152       MAILTO=paul
153       #
154       CRON_TZ=Japan
155       # run five minutes after midnight, every day
156       5 0 * * *       $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
157       # run at 2:15pm on the first of every month -- output mailed to paul
158       15 14 1 * *     $HOME/bin/monthly
159       # run at 10 pm on weekdays, annoy Joe
160       0 22 * * 1-5    mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
161       23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
162       5 4 * * sun     echo "run at 5 after 4 every sunday"
163

Jobs in /etc/cron.d/

165       The  jobs  in  cron.d  are system jobs, which are used usually for more
166       than one user. That's the reason why is name of the user needed. MAILTO
167       on the first line is optional.
168

EXAMPLE FOR JOB IN /etc/cron.d/job

170       #login as root
171       #create job with preferred editor (e.g. vim)
172       MAILTO=root
173       * * * * * root touch /tmp/file
174

SELinux with multi level security (MLS)

176       In crontab is important specified security level by crontab -s or spec‐
177       ifying the required level on the first line of the crontab. Each  level
178       is specified in /etc/selinux/targeted/seusers. For using crontab in MLS
179       mode is really important:
180       - check/change actual role,
181       - set correct role for directory, which is used for input/output.
182

EXAMPLE FOR SELINUX MLS

184       # login as root
185       newrole -r sysadm_r
186       mkdir /tmp/SystemHigh
187       chcon -l SystemHigh /tmp/SystemHigh
188       crontab -e
189       # write in crontab file
190       MLS_LEVEL=SystemHigh
191       0-59 * * * * id -Z > /tmp/SystemHigh/crontest
192       When I log in as a normal user, it can't work, because /tmp/SystemHigh is
193       higher than my level.
194

FILES

196       /etc/anacrontab system crontab file for jobs like  cron.daily,  weekly,
197       monthly.   /var/spool/cron/  usual  place  for  storing  users crontab.
198       /etc/cron.d/ stored system crontables.
199

SEE ALSO

201       cron(8), crontab(1)
202

EXTENSIONS

204       When specifying day of week, both day 0 and day 7  will  be  considered
205       Sunday.  BSD and ATT seem to disagree about this.
206
207       Lists  and ranges are allowed to co-exist in the same field.  "1-3,7-9"
208       would be rejected by ATT or BSD cron --  they  want  to  see  "1-3"  or
209       "7,8,9" ONLY.
210
211       Ranges can include "steps", so "1-9/2" is the same as "1,3,5,7,9".
212
213       Names of months or days of the week can be specified by name.
214
215       Environment  variables  can  be set in the crontab.  In BSD or ATT, the
216       environment handed  to  child  processes  is  basically  the  one  from
217       /etc/rc.
218
219       Command  output is mailed to the crontab owner (BSD can't do this), can
220       be mailed to a person other than  the  crontab  owner  (SysV  can't  do
221       this), or the feature can be turned off and no mail will be sent at all
222       (SysV can't do this either).
223
224       These special  time  specification  "nicknames"  are  supported,  which
225       replace the 5 initial time and date fields, and are prefixed by the '@'
226       character:
227       @reboot    :    Run once after reboot.
228       @yearly    :    Run once a year, ie.  "0 0 1 1 *".
229       @annually  :    Run once a year, ie.  "0 0 1 1 *".
230       @monthly   :    Run once a month, ie. "0 0 1 * *".
231       @weekly    :    Run once a week, ie.  "0 0 * * 0".
232       @daily     :    Run once a day, ie.   "0 0 * * *".
233       @hourly    :    Run once an hour, ie. "0 * * * *".
234

CAVEATS

236       The crontab files have to be  regular  files  or  symlinks  to  regular
237       files,  they must not be executable or writable by anyone else than the
238       owner.  This requirement can be overridden by using the  -p  option  on
239       the  crond  command  line.  If inotify support is in use changes in the
240       symlinked crontabs are not automatically noticed by  the  cron  daemon.
241       The  cron daemon must receive a SIGHUP to reload the crontabs.  This is
242       a limitation of inotify API.
243
244

AUTHOR

246       Paul Vixie <vixie@isc.org>
247
248
249
250Marcela Mašláňová                20 July 2009                    ANACRONTAB(5)
Impressum