1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
.\"/* Copyright 1988,1990,1993,1996 by Paul Vixie
.\" * All rights reserved
.\" */
.\"
.\" Copyright (c) 1997,2000 by Internet Software Consortium, Inc.
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
.\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
.\" CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
.\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
.\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
.\" SOFTWARE.
.\"
.\" $OpenBSD: cron.8,v 1.14 2002/05/09 21:22:01 millert Exp $
.\"
.Dd June 6, 1999
.Dt CRON 8
.Os
.Sh NAME
.Nm cron
.Nd daemon to execute scheduled commands (Vixie Cron)
.Sh SYNOPSIS
.Nm cron
.Sh DESCRIPTION
.Nm
should be started from
.Pa /etc/rc
or
.Pa /etc/rc.local .
It will return immediately, so you don't need to start it with
.Ql \&& .
Because it can execute commands on a user's behalf,
.Nm
should be run late in the startup sequence,
as close to the time when logins are accepted as possible.
.Pp
.Nm
searches its spool directory
.Pf ( Pa /var/cron/tabs Ns )
for
.Xr crontab 5
files which are named after accounts in
.Pa /etc/passwd ;
crontabs found are loaded into memory.
.Nm
also searches for
.Pa /etc/crontab
which is in a different format (see
.Xr crontab 5 ) .
.Nm
then wakes up every minute, examining all loaded crontabs, checking each
command to see if it should be run in the current minute.
When executing commands, any output is mailed to the user named in the
.Ev MAILTO
environment variable in the crontab, or to the owner of the crontab if
.Ev MAILTO
is not present.
.Pp
Additionally,
.Nm
checks each minute to see if its spool directory's modtime (or the modtime on
.Pa /etc/crontab )
has changed, and if it has,
.Nm
examines the modtime on all crontabs and reloads those which have
changed.
Thus
.Nm
need not be restarted whenever a crontab file is modified.
Note that the
.Xr crontab 1
command updates the modtime of the spool directory whenever it changes a
crontab.
.Pp
Special considerations exist when the clock is changed by less than 3
hours; for example, at the beginning and end of Daylight Saving
Time.
If the time has moved forward, those jobs which would have
run in the time that was skipped will be run soon after the change.
Conversely, if the time has moved backward by less than 3 hours,
those jobs that fall into the repeated time will not be run.
.Pp
Only jobs that run at a particular time (not specified as @hourly, nor with
.Ql *
in the hour or minute specifier)
are
affected.
Jobs which are specified with wildcards are run based on the
new time immediately.
.Pp
Clock changes of more than 3 hours are considered to be corrections to
the clock, and the new time is used immediately.
.Sh SIGNALS
.Bl -tag -width Ds
.It Dv SIGHUP
causes
.Nm
to close and reopen its log file.
This is useful in scripts which rotate and age log files.
On
.Ox
this has no effect because
.Nm cron
logs via
.Xr syslog 3 .
.El
.Sh FILES
.Bl -tag -width "/var/cron/tabs/.sock" -compact
.It Pa /var/cron/log
cron's log file
.It Pa /var/cron/tabs
directory of individual crontabs
.It Pa /var/cron/tabs/.sock
used by
.Xr crontab 1
to tell
.Nm
to check for crontab changes immediately
.El
.Sh SEE ALSO
.Xr crontab 1 ,
.Xr syslog 3 ,
.Xr crontab 5
.Sh AUTHORS
Paul Vixie <paul@vix.com>
|