summaryrefslogtreecommitdiff
path: root/usr.sbin/cron/cron.8
blob: 3f4e775b78647a007fe91b6a085e6f79b8fdac64 (plain)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
.\"
.\" Copyright (c) 2002-2003 Todd C. Miller <Todd.Miller@courtesan.com>
.\"
.\" 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 THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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.
.\"
.\" Sponsored in part by the Defense Advanced Research Projects
.\" Agency (DARPA) and Air Force Research Laboratory, Air Force
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
.\"
.\" $OpenBSD: cron.8,v 1.25 2004/02/24 19:39:48 jmc Exp $
.\"
.Dd July 6, 2002
.Dt CRON 8
.Os
.Sh NAME
.Nm cron
.Nd clock daemon
.Sh SYNOPSIS
.Nm cron
.Op Fl l Ar load_avg
.Op Fl n
.Op Fl x Ar [ext,sch,proc,pars,load,misc,test]
.Sh DESCRIPTION
The
.Nm
daemon schedules commands to be run at specified dates and times.
Commands that are to be run periodically are specified within
.Xr crontab 5
files.
Commands that are only to be run once are scheduled via the
.Xr at 1
and
.Xr batch 1
commands.
Normally, the
.Nm
daemon is started from the
.Pa /etc/rc
command script.
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
loads
.Xr crontab 5
and
.Xr at 1
files when it starts up and also when changes are made via the
.Xr crontab 1
and
.Xr at 1
commands.
Additionally,
.Nm
checks the modification time on the system crontab file
.Pq Pa /etc/crontab ,
the crontab spool
.Pq Pa /var/cron/tabs ,
and the at spool
.Pq Pa /var/cron/atjobs
once a minute.
If the modification time has changed, the affected files are reloaded.
.Pp
Any output produced by a command is sent to the user specified in the
.Ev MAILTO
environment variable as set in the
.Xr crontab 5
file or, if no
.Ev MAILTO
variable is set (or if this is an
.Xr at 1
or
.Xr batch 1
job), to the job's owner.
If a command produces no output, no mail will be sent.
The exception to this is
.Xr at 1
or
.Xr batch 1
jobs submitted with the
.Fl m
flag.
In this case, mail will be sent even if the job produces no output.
.Ss Daylight Saving Time and other time changes
Local time changes of less than three hours, such as those caused
by the start or end of Daylight Saving Time, are handled specially.
This only applies to jobs that run at a specific time and jobs that
are run with a granularity greater than one hour.
Jobs that run more frequently are scheduled normally.
.Pp
If time has moved forward, those jobs that would have run in the
interval that has been skipped will be run immediately.
Conversely, if time has moved backward, care is taken to avoid running
jobs twice.
.Pp
Time changes of more than 3 hours are considered to be corrections to
the clock or timezone, and the new time is used immediately.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl l Ar load_avg
If the current load average is greater than
.Ar load_avg ,
.Xr batch 1
jobs will not be run.
The default value is 1.5.
To allow
.Xr batch 1
jobs to run regardless of the load, a value of 0.0 may be used.
.It Fl n
By default,
.Nm
will detach from the current tty and become a daemon.
The
.Fl n
option disables this behavior and causes it to run in the foreground.
.It Fl x Ar debug_flags
If
.Nm
was compiled with debugging support, a number of debugging flags
are available to show what
.Nm
is doing.
The following flags may be specified:
.Bl -tag -width Ds
.It ext
show extended information; used in conjunction with other debug flags
to provide even more information
.It sch
print information related to scheduling jobs
.It proc
print information related to running processes
.It pars
print information related to parsing
.Xr crontab 5
files
.It load
print when loading the databases
.It misc
show misc other debugging information
.It test
test mode; don't actually execute commands
.El
.Pp
Multiple flags may be specified, separated by a comma
.Pq So , Sc .
Regardless of which flags were specified, the
.Fl x
flag will cause
.Nm
to stay in the foreground and not become a daemon.
.El
.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 /etc/crontab
system crontab file
.It Pa /var/cron/atjobs
directory containing
.Xr at 1
jobs
.It Pa /var/cron/log
cron's log file
.It Pa /var/cron/tabs
directory containing individual crontab files
.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 at 1 ,
.Xr crontab 1 ,
.Xr syslog 3 ,
.Xr crontab 5
.Sh AUTHORS
.An Paul Vixie Aq vixie@isc.org
.Sh CAVEATS
All
.Xr crontab 5
files must not be readable or writable by any user other than their owner,
including
.Pa /etc/crontab .
In practice this means they should be mode 0600.
This restriction is enforced automatically by
.Xr crontab 1
but if
.Pa /etc/crontab
is used, the mode must be set manually on that file.