xref: /netbsd-src/external/bsd/cron/dist/cron.8 (revision 6bc209b109763ffa58ce76a9f921a0f88fb0d4a2)
1*6bc209b1Swiz.\"	$NetBSD: cron.8,v 1.5 2011/10/12 22:50:31 wiz Exp $
20061c6a5Schristos.\"
30061c6a5Schristos.\" Id: cron.8,v 1.8 2004/01/23 19:03:32 vixie Exp
40061c6a5Schristos.\"
570b3f8cdSchristos.Dd October 12, 2011
6032a4398Schristos.Dt CRON 8
7032a4398Schristos.Os
8032a4398Schristos.Sh NAME
9032a4398Schristos.Nm cron
10032a4398Schristos.Nd daemon to execute scheduled commands (ISC Cron V4.1)
11032a4398Schristos.Sh SYNOPSIS
12032a4398Schristos.Nm
13032a4398Schristos.Op Fl n
14032a4398Schristos.Op Fl x Ar debugflags
15032a4398Schristos.Sh DESCRIPTION
16032a4398Schristos.Nm
17032a4398Schristosis normally started during system boot by
18032a4398Schristos.Xr rc.d 8
19032a4398Schristosframework, if cron is switched on in
20032a4398Schristos.Xr rc.conf 5 .
21032a4398Schristos.Pp
226f0c1d2eSwizIt will return immediately so you don't have to start it with
236f0c1d2eSwiz.Sq \*[Am] .
24032a4398Schristos.Pp
25032a4398Schristos.Nm
26032a4398Schristossearches
27032a4398Schristos.Pa /var/cron/tabs
28032a4398Schristosfor crontab files which are named after accounts in
29032a4398Schristos.Pa /etc/passwd .
30032a4398SchristosCrontabs found are loaded into memory.
31032a4398Schristos.Nm
32032a4398Schristosalso searches for
33032a4398Schristos.Pa /etc/crontab
34032a4398Schristoswhich is in a different format (see
35032a4398Schristos.Xr crontab 5 ) .
3670b3f8cdSchristosFinally
3770b3f8cdSchristos.Nm
3870b3f8cdSchristoslooks for crontabs in
3970b3f8cdSchristos.Pa /etc/cron.d
4070b3f8cdSchristosif it exists, and executes each file as a crontab.
4170b3f8cdSchristos.Pp
4270b3f8cdSchristosWhen
4370b3f8cdSchristos.Nm
4470b3f8cdSchristoslooks in a directory for crontabs (either in
4570b3f8cdSchristos.Pa /var/cron/tabs
4670b3f8cdSchristosor
4770b3f8cdSchristos.Pa /etc/cron.d )
4870b3f8cdSchristosit will not process files that:
4970b3f8cdSchristos.Bl -dash -compact -offset indent
5070b3f8cdSchristos.It
5170b3f8cdSchristosStart with a
5270b3f8cdSchristos.Sq \&.
5370b3f8cdSchristosor a
5470b3f8cdSchristos.Sq # .
5570b3f8cdSchristos.It
5670b3f8cdSchristosEnd with a
5770b3f8cdSchristos.Sq ~
5870b3f8cdSchristosor with
5970b3f8cdSchristos.Dq .rpmsave ,
6070b3f8cdSchristos.Dq .rpmorig ,
6170b3f8cdSchristosor
6270b3f8cdSchristos.Dq .rpmnew .
6370b3f8cdSchristos.It
6470b3f8cdSchristosAre of zero length.
6570b3f8cdSchristos.It
6670b3f8cdSchristosTheir length is greater than
6770b3f8cdSchristos.Dv MAXNAMLEN .
6870b3f8cdSchristos.El
6970b3f8cdSchristos.Pp
70032a4398Schristos.Nm
710061c6a5Schristosthen wakes up every minute, examining all stored crontabs, checking each
72032a4398Schristoscommand to see if it should be run in the current minute.
73032a4398SchristosWhen executing commands, any output is mailed to the owner of the
74032a4398Schristoscrontab (or to the user named in the
75032a4398Schristos.Ev MAILTO
76032a4398Schristosenvironment variable in the crontab, if such exists).
77032a4398Schristos.Pp
78032a4398SchristosEvents such as
79032a4398Schristos.Dv START
80032a4398Schristosand
81032a4398Schristos.Dv FINISH
82032a4398Schristosare recorded in the
83032a4398Schristos.Pa /var/log/cron
84032a4398Schristoslog file with date and time details.
85032a4398SchristosThis information is useful for a number of reasons, such as
86032a4398Schristosdetermining the amount of time required to run a particular job.
87032a4398SchristosBy default, root has an hourly job that rotates these log files
88032a4398Schristoswith compression to preserve disk space.
89032a4398Schristos.Pp
900061c6a5SchristosAdditionally,
91032a4398Schristos.Nm
920061c6a5Schristoschecks each minute to see if its spool directory's modtime (or the modtime
930061c6a5Schristoson
9470b3f8cdSchristos.Pa /etc/crontab
9570b3f8cdSchristosor
9670b3f8cdSchristos.Pa /etc/cron.d )
970061c6a5Schristoshas changed, and if it has,
98032a4398Schristos.Nm
990061c6a5Schristoswill then examine the modtime on all crontabs and reload those which have
100032a4398Schristoschanged.
101032a4398SchristosThus
102032a4398Schristos.Nm
103032a4398Schristosneed not be restarted whenever a crontab file is modified.
104032a4398SchristosNote that the
105032a4398Schristos.Xr crontab 1
1060061c6a5Schristoscommand updates the modtime of the spool directory whenever it changes a
1070061c6a5Schristoscrontab.
108032a4398Schristos.Pp
109032a4398SchristosThe following options are available:
110032a4398Schristos.Bl -tag -width indent
111032a4398Schristos.It Fl x
112032a4398SchristosThis  flag turns on some debugging flags.
113032a4398Schristos.Ar debugflags
114032a4398Schristosis comma-separated list of debugging flags to turn on.
115032a4398SchristosIf a flag is turned on,
116032a4398Schristos.Nm
117032a4398Schristoswrites some additional debugging information to system log during
118032a4398Schristosits work.
119032a4398SchristosAvailable debugging flags are:
120032a4398Schristos.Bl -tag -width proc -compact
121032a4398Schristos.It Ar sch
122032a4398Schristosscheduling
123032a4398Schristos.It Ar proc
124032a4398Schristosprocess control
125032a4398Schristos.It Ar pars
126032a4398Schristosparsing
127032a4398Schristos.It Ar load
128032a4398Schristosdatabase loading
129032a4398Schristos.It Ar misc
130032a4398Schristosmiscellaneous
131032a4398Schristos.It Ar test
132032a4398Schristostest mode - do not actually execute any commands
133032a4398Schristos.It Ar bit
134032a4398Schristosshow how various bits are set (long)
135032a4398Schristos.It Ar ext
136032a4398Schristosprint extended debugging information
137032a4398Schristos.El
138032a4398Schristos.It Fl n
139032a4398SchristosStay in the foreground and don't daemonize
140032a4398Schristos.Nm .
141032a4398Schristos.El
142032a4398Schristos.Sh Daylight Saving Time and other time changes
1430061c6a5SchristosLocal time changes of less than three hours, such as those caused
1440061c6a5Schristosby the start or end of Daylight Saving Time, are handled specially.
1450061c6a5SchristosThis only applies to jobs that run at a specific time and jobs that
146032a4398Schristosare run with a granularity greater than one hour.
147032a4398SchristosJobs that run more frequently are scheduled normally.
148032a4398Schristos.Pp
1490061c6a5SchristosIf time has moved forward, those jobs that would have run in the
1500061c6a5Schristosinterval that has been skipped will be run immediately.
1510061c6a5SchristosConversely, if time has moved backward, care is taken to avoid running
1520061c6a5Schristosjobs twice.
153032a4398Schristos.Pp
1540061c6a5SchristosTime changes of more than 3 hours are considered to be corrections to
1550061c6a5Schristosthe clock or timezone, and the new time is used immediately.
156032a4398Schristos.Sh SIGNALS
157032a4398SchristosOn receipt of a
158032a4398Schristos.Dv SIGHUP ,
159032a4398Schristosthe cron daemon will close and reopen its
160032a4398Schristoslog file.
161032a4398SchristosThis is useful in scripts which rotate and age log files.
1620061c6a5SchristosNaturally this is not relevant if cron was built to use
163032a4398Schristos.Xr syslog 3 .
164032a4398Schristos.Sh FILES
165032a4398Schristos.Bl -tag -width /var/cron/tabs -compact
166032a4398Schristos.It Pa /var/cron/tabs
167032a4398Schristos.Nm
168032a4398Schristosspool directory
169032a4398Schristos.It Pa /etc/crontab
17070b3f8cdSchristossystem crontab file
17170b3f8cdSchristos.It Pa /etc/cron.d/
17270b3f8cdSchristossystem crontab directory
173032a4398Schristos.It Pa /var/log/cron
174032a4398Schristoslog file for cron events
175032a4398Schristos.El
176032a4398Schristos.Sh SEE ALSO
177032a4398Schristos.Xr crontab 1 ,
178032a4398Schristos.Xr crontab 5
179032a4398Schristos.Sh AUTHORS
180032a4398Schristos.An Paul Vixie
181032a4398Schristos.Aq vixie@isc.org
182