xref: /freebsd/usr.sbin/cron/cron/cron.8 (revision d6b92ffa)
1.\"/* Copyright 1988,1990,1993 by Paul Vixie
2.\" * All rights reserved
3.\" *
4.\" * Distribute freely, except: don't remove my name from the source or
5.\" * documentation (don't take credit for my work), mark your changes (don't
6.\" * get me blamed for your possible bugs), don't alter or remove this
7.\" * notice.  May be sold if buildable source is provided to buyer.  No
8.\" * warrantee of any kind, express or implied, is included with this
9.\" * software; use at your own risk, responsibility for damages (if any) to
10.\" * anyone resulting from the use of this software rests entirely with the
11.\" * user.
12.\" *
13.\" * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
14.\" * I'll try to keep a version up to date.  I can be reached as follows:
15.\" * Paul Vixie          <paul@vix.com>          uunet!decwrl!vixie!paul
16.\" */
17.\"
18.\" $FreeBSD$
19.\"
20.Dd July 19, 2017
21.Dt CRON 8
22.Os
23.Sh NAME
24.Nm cron
25.Nd daemon to execute scheduled commands (Vixie Cron)
26.Sh SYNOPSIS
27.Nm
28.Op Fl j Ar jitter
29.Op Fl J Ar rootjitter
30.Op Fl m Ar mailto
31.Op Fl n
32.Op Fl s
33.Op Fl o
34.Op Fl x Ar debugflag Ns Op , Ns Ar ...
35.Sh DESCRIPTION
36The
37.Nm
38utility should be started from
39.Pa /etc/rc
40or
41.Pa /etc/rc.local .
42It will return immediately,
43so you do not need to start it with '&'.
44.Pp
45The
46.Nm
47utility searches
48.Pa /var/cron/tabs
49for crontab files which are named after accounts in
50.Pa /etc/passwd ;
51crontabs found are loaded into memory.
52The
53.Nm
54utility also searches for
55.Pa /etc/crontab
56and files in
57.Pa /etc/cron.d
58and
59.Pa /usr/local/etc/cron.d
60which are in a different format (see
61.Xr crontab 5 ) .
62.Pp
63The
64.Nm
65utility
66then wakes up every minute, examining all stored crontabs, checking each
67command to see if it should be run in the current minute.
68Before running a command from a per-account crontab file,
69.Nm
70checks the status of the account with
71.Xr pam 3
72and skips the command if the account is unavailable,
73e.g., locked out or expired.
74Commands from
75.Pa /etc/crontab
76bypass this check.
77When executing
78commands, any output is mailed to the owner of the crontab (or to the user
79named in the
80.Ev MAILTO
81environment variable in the crontab, if such exists).
82.Pp
83Additionally,
84.Nm
85checks each minute to see if its spool directory's modification time (or
86the modification time on
87.Pa /etc/crontab )
88has changed, and if it has,
89.Nm
90will then examine the modification time on all crontabs and reload those
91which have changed.
92Thus
93.Nm
94need not be restarted whenever a crontab file is modified.
95Note that the
96.Xr crontab 1
97command updates the modification time of the spool directory whenever it
98changes a crontab.
99.Pp
100Available options:
101.Bl -tag -width indent
102.It Fl j Ar jitter
103Enable time jitter.
104Prior to executing commands,
105.Nm
106will sleep a random number of seconds in the range from 0 to
107.Ar jitter .
108This will not affect superuser jobs (see
109.Fl J ) .
110A value for
111.Ar jitter
112must be between 0 and 60 inclusive.
113Default is 0, which effectively disables time jitter.
114.Pp
115This option can help to smooth down system load spikes during
116moments when a lot of jobs are likely to start at once, e.g.,
117at the beginning of the first minute of each hour.
118.It Fl J Ar rootjitter
119Enable time jitter for superuser jobs.
120The same as
121.Fl j
122except that it will affect jobs run by the superuser only.
123.It Fl m Ar mailto
124Overrides the default recipient for
125.Nm
126mail.
127Each
128.Xr crontab 5
129without
130.Ev MAILTO
131explicitly set will send mail to the
132.Ar mailto
133mailbox.
134Sending mail will be disabled by default if
135.Ar mailto
136set to a null string, usually specified in a shell as
137.Li ''
138or
139.Li \*q\*q .
140.It Fl n
141Do not daemonize; run in foreground instead.
142.It Fl s
143Enable special handling of situations when the GMT offset of the local
144timezone changes, such as the switches between the standard time and
145daylight saving time.
146.Pp
147The jobs run during the GMT offset changes time as
148intuitively expected.
149If a job falls into a time interval that disappears
150(for example, during the switch from
151standard time) to daylight saving time or is
152duplicated (for example, during the reverse switch), then it is handled
153in one of two ways:
154.Pp
155The first case is for the jobs that run every at hour of a time interval
156overlapping with the disappearing or duplicated interval.
157In other words, if the job had run within one hour before the GMT offset change
158(and cron was not restarted nor the
159.Xr crontab 5
160changed after that)
161or would run after the change at the next hour.
162They work as always, skip the skipped time or run in the added
163time as usual.
164.Pp
165The second case is for the jobs that run less frequently.
166They are executed exactly once, they are not skipped nor
167executed twice (unless cron is restarted or the user's
168.Xr crontab 5
169is changed during such a time interval).
170If an interval disappears
171due to the GMT offset change, such jobs are
172executed at the same absolute point of time as they would be in the
173old time zone.
174For example, if exactly one hour disappears, this
175point would be during the next hour at the first minute that is
176specified for them in
177.Xr crontab 5 .
178.It Fl o
179Disable the special handling of situations when the GMT offset of the local
180timezone changes, to be compatible with the old (default) behavior.
181If both options
182.Fl o
183and
184.Fl s
185are specified, the option specified last wins.
186.It Fl x Ar debugflag Ns Op , Ns Ar ...
187Enable writing of debugging information to standard output.
188One or more of the following comma separated
189.Ar debugflag
190identifiers must be specified:
191.Pp
192.Bl -tag -width ".Cm proc" -compact
193.It Cm bit
194currently not used
195.It Cm ext
196make the other debug flags more verbose
197.It Cm load
198be verbose when loading crontab files
199.It Cm misc
200be verbose about miscellaneous one-off events
201.It Cm pars
202be verbose about parsing individual crontab lines
203.It Cm proc
204be verbose about the state of the process, including all of its offspring
205.It Cm sch
206be verbose when iterating through the scheduling algorithms
207.It Cm test
208trace through the execution, but do not perform any actions
209.El
210.El
211.Sh FILES
212.Bl -tag -width /usr/local/etc/cron.d -compact
213.It Pa /etc/crontab
214System crontab file
215.It Pa /etc/cron.d
216Directory for optional/modularized system crontab files.
217.It Pa /etc/pam.d/cron
218.Xr pam.conf 5
219configuration file for
220.Nm
221.It Pa /usr/local/etc/cron.d
222Directory for third-party package provided crontab files.
223.It Pa /var/cron/tabs
224Directory for personal crontab files
225.El
226.Sh SEE ALSO
227.Xr crontab 1 ,
228.Xr pam 3 ,
229.Xr crontab 5 ,
230.Xr pam.conf 5
231.Sh AUTHORS
232.An Paul Vixie Aq Mt paul@vix.com
233