Debian Codegraph @

upstream/opensuse-tumbleweed/man8/cron.8

raw
1 .\"/* Copyright 1988,1990,1993,1996 by Paul Vixie
2 .\" * All rights reserved
3 .\" */
4 .\"
5 .\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
6 .\" Copyright (c) 1997,2000 by Internet Software Consortium, Inc.
7 .\"
8 .\" Permission to use, copy, modify, and distribute this software for any
9 .\" purpose with or without fee is hereby granted, provided that the above
10 .\" copyright notice and this permission notice appear in all copies.
11 .\"
12 .\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
13 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
15 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
18 .\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 .\"
20 .\" Modified 2010/09/12 by Colin Dean, Durham University IT Service,
21 .\" to add clustering support.
22 .\"
23 .\" $Id: cron.8,v 1.8 2004/01/23 19:03:32 vixie Exp $
24 .\"
25 .TH CRON "8" "2013-09-26" "cronie" "System Administration"
26 .SH NAME
27 crond \- daemon to execute scheduled commands
28 .SH SYNOPSIS
29 .B crond
30 .RB [ -c " | " -h " | " -i " | " -n " | " -p " | " -P " | " -s " | " -m \fP\fI<mail command>\fP ]
31 .br
32 .B crond
33 .B -x
34 .RB [ext,sch,proc,pars,load,misc,test,bit]
35 .br
36 .B crond
37 .B -V
38 .SH DESCRIPTION
39 .I Cron
40 is started from
41 .I /etc/rc.d/init.d
42 or
43 .I /etc/init.d
44 when classical sysvinit scripts are used. In case systemd is enabled, then unit file is installed into
45 .I /lib/systemd/system/crond.service
46 and daemon is started by
47 .I systemctl start crond.service
48 command. It returns immediately, thus, there is no need to need to start it with
49 the '&' parameter.
50 .PP
51 .I Cron
52 searches
53 .I /var/spool/cron
54 for crontab files which are named after accounts in
55 .I /etc/passwd;
56 The found crontabs are loaded into the memory.
57 .I Cron
58 also searches for
59 .I /etc/crontab
60 and any files in the
61 .I /etc/cron.d
62 directory, which have a different format (see
63 .BR crontab (5)).
64 .I Cron
65 examines all stored crontabs and checks each job to see if it needs to be
66 run in the current minute. When executing commands, any output is mailed
67 to the owner of the crontab (or to the user specified in the
68 .I MAILTO
69 environment variable in the crontab, if such exists). Any job output can
70 also be sent to syslog by using the
71 .B "\-s"
72 option.
73 .PP
74 There are two ways how changes in crontables are checked. The first
75 method is checking the modtime of a file. The second method is using the
76 inotify support. Using of inotify is logged in the
77 .I /var/log/cron
78 log after the daemon is started. The inotify support checks for changes
79 in all crontables and accesses the hard disk only when a change is
80 detected.
81 .PP
82 When using the modtime option,
83 .I Cron
84 checks its crontables' modtimes every minute to check for any changes and
85 reloads the crontables which have changed. There is no need to restart
86 .I Cron
87 after some of the crontables were modified. The modtime option is also
88 used when inotify can not be initialized.
89 .PP
90 .I Cron
91 checks these files and directories:
92 .TP
93 .IR /etc/crontab
94 system crontab. Nowadays the file is empty by default. Originally it
95 was usually used to run daily, weekly, monthly jobs. By default these
96 jobs are now run through anacron which reads
97 .IR /etc/anacrontab
98 configuration file. See
99 .BR anacrontab (5)
100 for more details.
101 .TP
102 .IR /etc/cron.d/
103 directory that contains system cronjobs stored for different users.
104 .TP
105 .IR /var/spool/cron
106 directory that contains user crontables created by the
107 .IR crontab
108 command.
109 .PP
110 Note that the
111 .BR crontab (1)
112 command updates the modtime of the spool directory whenever it changes a
113 crontab.
114 .PP
115 .SS Daylight Saving Time and other time changes
116 Local time changes of less than three hours, such as those caused by the
117 Daylight Saving Time changes, are handled in a special way. This only
118 applies to jobs that run at a specific time and jobs that run with a
119 granularity greater than one hour. Jobs that run more frequently are
120 scheduled normally.
121 .PP
122 If time was adjusted one hour forward, those jobs that would have run in
123 the interval that has been skipped will be run immediately. Conversely,
124 if time was adjusted backward, running the same job twice is avoided.
125 .PP
126 Time changes of more than 3 hours are considered to be corrections to the
127 clock or the timezone, and the new time is used immediately.
128 .PP
129 It is possible to use different time zones for crontables. See
130 .BR crontab (5)
131 for more information.
132 .SS PAM Access Control
133 .IR Cron
134 supports access control with PAM if the system has PAM installed. For
135 more information, see
136 .BR pam (8).
137 A PAM configuration file for
138 .IR crond
139 is installed in
140 .IR /etc/pam.d/crond .
141 The daemon loads the PAM environment from the pam_env module. This can
142 be overridden by defining specific settings in the appropriate crontab
143 file.
144 .SH "OPTIONS"
145 .TP
146 .B "\-h"
147 Prints a help message and exits.
148 .TP
149 .B "\-i"
150 Disables inotify support.
151 .TP
152 .B "\-m"
153 This option allows you to specify a shell command to use for sending
154 .I Cron
155 mail output instead of using
156 .BR sendmail (8)
157 This command must accept a fully formatted mail message (with headers) on
158 standard input and send it as a mail message to the recipients specified
159 in the mail headers. Specifying the string
160 .I "off"
161 (i.e., crond -m off)
162 will disable the sending of mail.
163 .TP
164 .B "\-n"
165 Tells the daemon to run in the foreground. This can be useful when
166 starting it out of init. With this option is needed to change pam setting.
167 .I /etc/pam.d/crond
168 must not enable
169 .I pam_loginuid.so
170 module.
171 .TP
172 .B "\-f"
173 the same as -n, consistent with other crond implementations.
174 .TP
175 .B "\-p"
176 Allows
177 .I Cron
178 to accept any user set crontables.
179 .TP
180 .B "\-P"
181 Don't set PATH. PATH is instead inherited from the environment.
182 .TP
183 .B "\-c"
184 This option enables clustering support, as described below.
185 .TP
186 .B "\-s"
187 This option will direct
188 .I Cron
189 to send the job output to the system log using
190 .BR syslog (3).
191 This is useful if your system does not have
192 .BR sendmail (8)
193 installed or if mail is disabled.
194 .TP
195 .B "\-x"
196 This option allows you to set debug flags.
197 .TP
198 .B "\-V"
199 Print version and exit.
200 .SH SIGNALS
201 When the
202 .I SIGHUP
203 is received, the
204 .I Cron
205 daemon will close and reopen its log file. This proves to be useful in
206 scripts which rotate and age log files. Naturally, this is not relevant
207 if
208 .I Cron
209 was built to use
210 .IR syslog (3).
211 .SH CLUSTERING SUPPORT
212 In this version of
213 .IR Cron
214 it is possible to use a network-mounted shared
215 .I /var/spool/cron
216 across a cluster of hosts and specify that only one of the hosts should
217 run the crontab jobs in this directory at any one time. This is done by
218 starting
219 .I Cron
220 with the
221 .B \-c
222 option, and have the
223 .I /var/spool/cron/.cron.hostname
224 file contain just one line, which represents the hostname of whichever
225 host in the cluster should run the jobs. If this file does not exist, or
226 the hostname in it does not match that returned by
227 .BR gethostname (2),
228 then all crontab files in this directory are ignored. This has no effect
229 on cron jobs specified in the
230 .I /etc/crontab
231 file or on files in the
232 .I /etc/cron.d
233 directory. These files are always run and considered host-specific.
234 .PP
235 Rather than editing
236 .I /var/spool/cron/.cron.hostname
237 directly, use the
238 .B \-n
239 option of
240 .BR crontab (1)
241 to specify the host.
242 .PP
243 You should ensure that all hosts in a cluster, and the file server from
244 which they mount the shared crontab directory, have closely synchronised
245 clocks, e.g., using
246 .BR ntpd (8),
247 otherwise the results will be very unpredictable.
248 .PP
249 Using cluster sharing automatically disables inotify support, because
250 inotify cannot be relied on with network-mounted shared file systems.
251 .SH CAVEATS
252 All
253 .BR crontab
254 files have to be regular files or symlinks to regular files, they must
255 not be executable or writable for anyone else but the owner. This
256 requirement can be overridden by using the
257 .B \-p
258 option on the crond command line. If inotify support is in use, changes
259 in the symlinked crontabs are not automatically noticed by the cron
260 daemon. The cron daemon must receive a SIGHUP signal to reload the
261 crontabs. This is a limitation of the inotify API.
262 .PP
263 The syslog output will be used instead of mail, when sendmail is not
264 installed.
265 .SH "SEE ALSO"
266 .BR crontab (1),
267 .BR crontab (5),
268 .BR inotify (7),
269 .BR pam (8)
270 .SH AUTHOR
271 .MT [email protected]
272 Paul Vixie
273 .ME
274 .br
275 .MT [email protected]
276 Marcela Mašláňová
277 .ME
278 .br
279 .MT [email protected]
280 Colin Dean
281 .ME
282 .br
283 .MT [email protected]
284 Tomáš Mráz
285 .ME