xref: /openbsd-src/usr.sbin/cron/cron.8 (revision bf198cc6eba0ca1f6d79f71e8e2243d386241fa8)
1.\"
2.\" Copyright (c) 2002-2003 Todd C. Miller <millert@openbsd.org>
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.36 2019/01/25 00:19:27 millert Exp $
21.\"
22.Dd $Mdocdate: January 25 2019 $
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.Sh DESCRIPTION
33The
34.Nm
35daemon schedules commands to be run at specified dates and times.
36Commands that are to be run periodically are specified within
37.Xr crontab 5
38files.
39Commands that are only to be run once are scheduled via the
40.Xr at 1
41and
42.Xr batch 1
43commands.
44Normally, the
45.Nm
46daemon is started from the
47.Pa /etc/rc
48command script.
49Because it can execute commands on a user's behalf,
50.Nm
51should be run late in the startup sequence,
52as close to the time when logins are accepted as possible.
53.Pp
54.Nm
55loads
56.Xr crontab 5
57and
58.Xr at 1
59files when it starts up and also when changes are made via the
60.Xr crontab 1
61and
62.Xr at 1
63commands.
64Additionally,
65.Nm
66checks the modification time on the system crontab file
67.Pq Pa /etc/crontab ,
68the crontab spool
69.Pq Pa /var/cron/tabs ,
70and the at spool
71.Pq Pa /var/cron/atjobs
72once a minute.
73If the modification time has changed, the affected files are reloaded.
74.Pp
75Any output produced by a command is sent to the user specified in the
76.Ev MAILTO
77environment variable as set in the
78.Xr crontab 5
79file or, if no
80.Ev MAILTO
81variable is set (or if this is an
82.Xr at 1
83or
84.Xr batch 1
85job), to the job's owner.
86If a command produces no output or if the
87.Ev MAILTO
88environment variable is set to the empty string, no mail will be sent.
89The exception to this is
90.Xr at 1
91or
92.Xr batch 1
93jobs submitted with the
94.Fl m
95flag.
96In this case, mail will be sent even if the job produces no output.
97.Ss Daylight Saving Time and other time changes
98Local time changes of less than three hours, such as those caused
99by the start or end of Daylight Saving Time, are handled specially.
100This only applies to jobs that run at a specific time and jobs that
101are run with a granularity greater than one hour.
102Jobs that run more frequently are scheduled normally.
103.Pp
104If time has moved forward, those jobs that would have run in the
105interval that has been skipped will be run immediately.
106Conversely, if time has moved backward, care is taken to avoid running
107jobs twice.
108.Pp
109Time changes of more than 3 hours are considered to be corrections to
110the clock or time zone, and the new time is used immediately.
111.Pp
112The options are as follows:
113.Bl -tag -width Ds
114.It Fl l Ar load_avg
115If the current load average is greater than
116.Ar load_avg ,
117.Xr batch 1
118jobs will not be run.
119The default value is 1.5.
120To allow
121.Xr batch 1
122jobs to run regardless of the load, a value of 0.0 may be used.
123.It Fl n
124By default,
125.Nm
126will detach from the current tty and become a daemon.
127The
128.Fl n
129option disables this behavior and causes it to run in the foreground.
130.El
131.Sh FILES
132.Bl -tag -width "/var/run/cron.sock" -compact
133.It Pa /etc/crontab
134system crontab file
135.It Pa /var/cron/atjobs
136directory containing
137.Xr at 1
138jobs
139.It Pa /var/cron/log
140cron's log file
141.It Pa /var/cron/tabs
142directory containing individual crontab files
143.It Pa /var/run/cron.sock
144used by
145.Xr crontab 1
146to tell
147.Nm
148to check for crontab changes immediately
149.El
150.Sh SEE ALSO
151.Xr at 1 ,
152.Xr crontab 1 ,
153.Xr syslog 3 ,
154.Xr crontab 5
155.Sh AUTHORS
156.An Paul Vixie Aq Mt vixie@isc.org
157.Sh CAVEATS
158.Xr crontab 5
159files will be ignored if they do not have the proper file mode.
160For user crontab files created by
161.Xr crontab 1 ,
162the mode must be 0600.
163If the system crontab file is used,
164.Pa /etc/crontab
165must not be writable by any user other than root and must not have
166the execute, set-user-ID, set-group-ID or sticky bits set.
167