xref: /openbsd-src/usr.sbin/cron/cron.8 (revision a28daedfc357b214be5c701aa8ba8adb29a7f1c2)
1.\"
2.\" Copyright (c) 2002-2003 Todd C. Miller <Todd.Miller@courtesan.com>
3.\"
4.\" Permission to use, copy, modify, and distribute this software for any
5.\" purpose with or without fee is hereby granted, provided that the above
6.\" copyright notice and this permission notice appear in all copies.
7.\"
8.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\"
16.\" Sponsored in part by the Defense Advanced Research Projects
17.\" Agency (DARPA) and Air Force Research Laboratory, Air Force
18.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
19.\"
20.\" $OpenBSD: cron.8,v 1.30 2007/05/31 19:20:23 jmc Exp $
21.\"
22.Dd $Mdocdate: May 31 2007 $
23.Dt CRON 8
24.Os
25.Sh NAME
26.Nm cron
27.Nd clock daemon
28.Sh SYNOPSIS
29.Nm cron
30.Op Fl n
31.Op Fl l Ar load_avg
32.Oo
33.Fl x
34.Sm off
35.Oo Ar ext , sch , proc ,
36.Ar pars , load , misc , test
37.Oc
38.Sm on
39.Oc
40.Sh DESCRIPTION
41The
42.Nm
43daemon schedules commands to be run at specified dates and times.
44Commands that are to be run periodically are specified within
45.Xr crontab 5
46files.
47Commands that are only to be run once are scheduled via the
48.Xr at 1
49and
50.Xr batch 1
51commands.
52Normally, the
53.Nm
54daemon is started from the
55.Pa /etc/rc
56command script.
57Because it can execute commands on a user's behalf,
58.Nm
59should be run late in the startup sequence,
60as close to the time when logins are accepted as possible.
61.Pp
62.Nm
63loads
64.Xr crontab 5
65and
66.Xr at 1
67files when it starts up and also when changes are made via the
68.Xr crontab 1
69and
70.Xr at 1
71commands.
72Additionally,
73.Nm
74checks the modification time on the system crontab file
75.Pq Pa /etc/crontab ,
76the crontab spool
77.Pq Pa /var/cron/tabs ,
78and the at spool
79.Pq Pa /var/cron/atjobs
80once a minute.
81If the modification time has changed, the affected files are reloaded.
82.Pp
83Any output produced by a command is sent to the user specified in the
84.Ev MAILTO
85environment variable as set in the
86.Xr crontab 5
87file or, if no
88.Ev MAILTO
89variable is set (or if this is an
90.Xr at 1
91or
92.Xr batch 1
93job), to the job's owner.
94If a command produces no output or if the
95.Ev MAILTO
96environment variable is set to the empty string, no mail will be sent.
97The exception to this is
98.Xr at 1
99or
100.Xr batch 1
101jobs submitted with the
102.Fl m
103flag.
104In this case, mail will be sent even if the job produces no output.
105.Ss Daylight Saving Time and other time changes
106Local time changes of less than three hours, such as those caused
107by the start or end of Daylight Saving Time, are handled specially.
108This only applies to jobs that run at a specific time and jobs that
109are run with a granularity greater than one hour.
110Jobs that run more frequently are scheduled normally.
111.Pp
112If time has moved forward, those jobs that would have run in the
113interval that has been skipped will be run immediately.
114Conversely, if time has moved backward, care is taken to avoid running
115jobs twice.
116.Pp
117Time changes of more than 3 hours are considered to be corrections to
118the clock or time zone, and the new time is used immediately.
119.Pp
120The options are as follows:
121.Bl -tag -width Ds
122.It Fl l Ar load_avg
123If the current load average is greater than
124.Ar load_avg ,
125.Xr batch 1
126jobs will not be run.
127The default value is 1.5.
128To allow
129.Xr batch 1
130jobs to run regardless of the load, a value of 0.0 may be used.
131.It Fl n
132By default,
133.Nm
134will detach from the current tty and become a daemon.
135The
136.Fl n
137option disables this behavior and causes it to run in the foreground.
138.It Fl x Ar debug_flags
139If
140.Nm
141was compiled with debugging support, a number of debugging flags
142are available to show what
143.Nm
144is doing.
145The following flags may be specified:
146.Bl -tag -width Ds
147.It ext
148show extended information; used in conjunction with other debug flags
149to provide even more information
150.It sch
151print information related to scheduling jobs
152.It proc
153print information related to running processes
154.It pars
155print information related to parsing
156.Xr crontab 5
157files
158.It load
159print when loading the databases
160.It misc
161show misc other debugging information
162.It test
163test mode; don't actually execute commands
164.El
165.Pp
166Multiple flags may be specified, separated by a comma
167.Pq So , Sc .
168Regardless of which flags were specified, the
169.Fl x
170flag will cause
171.Nm
172to stay in the foreground and not become a daemon.
173.El
174.Sh SIGNALS
175.Bl -tag -width Ds
176.It Dv SIGHUP
177causes
178.Nm
179to close and reopen its log file.
180This is useful in scripts which rotate and age log files.
181On
182.Ox
183this has no effect because
184.Nm cron
185logs via
186.Xr syslog 3 .
187.El
188.Sh FILES
189.Bl -tag -width "/var/cron/tabs/.sock" -compact
190.It Pa /etc/crontab
191system crontab file
192.It Pa /var/cron/atjobs
193directory containing
194.Xr at 1
195jobs
196.It Pa /var/cron/log
197cron's log file
198.It Pa /var/cron/tabs
199directory containing individual crontab files
200.It Pa /var/cron/tabs/.sock
201used by
202.Xr crontab 1
203to tell
204.Nm
205to check for crontab changes immediately
206.El
207.Sh SEE ALSO
208.Xr at 1 ,
209.Xr crontab 1 ,
210.Xr syslog 3 ,
211.Xr crontab 5
212.Sh AUTHORS
213.An Paul Vixie Aq vixie@isc.org
214.Sh CAVEATS
215.Xr crontab 5
216files will be ignored if they do not have the proper file mode.
217For user crontab files created by
218.Xr crontab 1 ,
219the mode must be 0400 or 0600.
220If the system crontab file is used,
221.Pa /etc/crontab
222must not be writable by any user other than root.
223