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