cronie/man/cron.8

286 lines
8.4 KiB
Groff
Raw Permalink Normal View History

2017-05-08 15:30:03 +02:00
.\"/* Copyright 1988,1990,1993,1996 by Paul Vixie
.\" * All rights reserved
.\" */
2019-08-06 18:08:05 +02:00
.\"
2017-05-08 15:30:03 +02:00
.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
.\" 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 ISC DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC 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.
.\"
.\" Modified 2010/09/12 by Colin Dean, Durham University IT Service,
.\" to add clustering support.
.\"
.\" $Id: cron.8,v 1.8 2004/01/23 19:03:32 vixie Exp $
2019-08-06 18:08:05 +02:00
.\"
.TH CRON "8" "2013-09-26" "cronie" "System Administration"
2017-05-08 15:30:03 +02:00
.SH NAME
crond \- daemon to execute scheduled commands
.SH SYNOPSIS
.B crond
2019-08-06 18:08:05 +02:00
.RB [ -c " | " -h " | " -i " | " -n " | " -p " | " -P " | " -s " | " -m \fP\fI<mail command>\fP ]
.br
2017-05-08 15:30:03 +02:00
.B crond
2019-08-06 18:08:05 +02:00
.B -x
2017-05-08 15:30:03 +02:00
.RB [ext,sch,proc,pars,load,misc,test,bit]
.br
2019-08-06 18:08:05 +02:00
.B crond
.B -V
2017-05-08 15:30:03 +02:00
.SH DESCRIPTION
.I Cron
2019-08-06 18:08:05 +02:00
is started from
.I /etc/rc.d/init.d
or
2017-05-08 15:30:03 +02:00
.I /etc/init.d
2019-08-06 18:08:05 +02:00
when classical sysvinit scripts are used. In case systemd is enabled, then unit file is installed into
.I /lib/systemd/system/crond.service
and daemon is started by
.I systemctl start crond.service
command. It returns immediately, thus, there is no need to need to start it with
the '&' parameter.
2017-05-08 15:30:03 +02:00
.PP
.I Cron
2019-08-06 18:08:05 +02:00
searches
.I /var/spool/cron
2017-05-08 15:30:03 +02:00
for crontab files which are named after accounts in
.I /etc/passwd;
The found crontabs are loaded into the memory.
.I Cron
2019-08-06 18:08:05 +02:00
also searches for
2017-05-08 15:30:03 +02:00
.I /etc/anacrontab
2019-08-06 18:08:05 +02:00
and any files in the
.I /etc/cron.d
2017-05-08 15:30:03 +02:00
directory, which have a different format (see
.BR crontab (5)).
.I Cron
examines all stored crontabs and checks each job to see if it needs to be
2019-08-06 18:08:05 +02:00
run in the current minute. When executing commands, any output is mailed
to the owner of the crontab (or to the user specified in the
.I MAILTO
environment variable in the crontab, if such exists). Any job output can
also be sent to syslog by using the
2017-05-08 15:30:03 +02:00
.B "\-s"
option.
.PP
2019-08-06 18:08:05 +02:00
There are two ways how changes in crontables are checked. The first
method is checking the modtime of a file. The second method is using the
inotify support. Using of inotify is logged in the
2017-05-08 15:30:03 +02:00
.I /var/log/cron
2019-08-06 18:08:05 +02:00
log after the daemon is started. The inotify support checks for changes
in all crontables and accesses the hard disk only when a change is
detected.
2017-05-08 15:30:03 +02:00
.PP
When using the modtime option,
.I Cron
2019-08-06 18:08:05 +02:00
checks its crontables' modtimes every minute to check for any changes and
reloads the crontables which have changed. There is no need to restart
.I Cron
after some of the crontables were modified. The modtime option is also
used when inotify can not be initialized.
2017-05-08 15:30:03 +02:00
.PP
.I Cron
checks these files and directories:
2019-08-06 18:08:05 +02:00
.TP
.IR /etc/crontab
system crontab. Nowadays the file is empty by default. Originally it
was usually used to run daily, weekly, monthly jobs. By default these
jobs are now run through anacron which reads
2017-05-08 15:30:03 +02:00
.IR /etc/anacrontab
2019-08-06 18:08:05 +02:00
configuration file. See
2017-05-08 15:30:03 +02:00
.BR anacrontab (5)
for more details.
2019-08-06 18:08:05 +02:00
.TP
2017-05-08 15:30:03 +02:00
.IR /etc/cron.d/
directory that contains system cronjobs stored for different users.
2019-08-06 18:08:05 +02:00
.TP
2017-05-08 15:30:03 +02:00
.IR /var/spool/cron
directory that contains user crontables created by the
2019-08-06 18:08:05 +02:00
.IR crontab
2017-05-08 15:30:03 +02:00
command.
2019-08-06 18:08:05 +02:00
.PP
2017-05-08 15:30:03 +02:00
Note that the
.BR crontab (1)
command updates the modtime of the spool directory whenever it changes a
crontab.
.PP
.SS Daylight Saving Time and other time changes
2019-08-06 18:08:05 +02:00
Local time changes of less than three hours, such as those caused by the
Daylight Saving Time changes, are handled in a special way. This only
applies to jobs that run at a specific time and jobs that run with a
granularity greater than one hour. Jobs that run more frequently are
scheduled normally.
2017-05-08 15:30:03 +02:00
.PP
2019-08-06 18:08:05 +02:00
If time was adjusted one hour forward, those jobs that would have run in
the interval that has been skipped will be run immediately. Conversely,
if time was adjusted backward, running the same job twice is avoided.
2017-05-08 15:30:03 +02:00
.PP
2019-08-06 18:08:05 +02:00
Time changes of more than 3 hours are considered to be corrections to the
clock or the timezone, and the new time is used immediately.
2017-05-08 15:30:03 +02:00
.PP
2019-08-06 18:08:05 +02:00
It is possible to use different time zones for crontables. See
.BR crontab (5)
for more information.
2017-05-08 15:30:03 +02:00
.SS PAM Access Control
.IR Cron
2019-08-06 18:08:05 +02:00
supports access control with PAM if the system has PAM installed. For
more information, see
.BR pam (8).
A PAM configuration file for
.IR crond
is installed in
2017-05-08 15:30:03 +02:00
.IR /etc/pam.d/crond .
2019-08-06 18:08:05 +02:00
The daemon loads the PAM environment from the pam_env module. This can
be overridden by defining specific settings in the appropriate crontab
file.
2017-05-08 15:30:03 +02:00
.SH "OPTIONS"
.TP
2019-08-06 18:08:05 +02:00
.B "\-h"
Prints a help message and exits.
.TP
.B "\-i"
Disables inotify support.
.TP
2017-05-08 15:30:03 +02:00
.B "\-m"
2019-08-06 18:08:05 +02:00
This option allows you to specify a shell command to use for sending
.I Cron
2017-05-08 15:30:03 +02:00
mail output instead of using
.BR sendmail (8)
2019-08-06 18:08:05 +02:00
This command must accept a fully formatted mail message (with headers) on
standard input and send it as a mail message to the recipients specified
in the mail headers. Specifying the string
.I "off"
(i.e., crond -m off)
2017-05-08 15:30:03 +02:00
will disable the sending of mail.
.TP
.B "\-n"
2019-08-06 18:08:05 +02:00
Tells the daemon to run in the foreground. This can be useful when
starting it out of init. With this option is needed to change pam setting.
.I /etc/pam.d/crond
must not enable
.I pam_loginuid.so
module.
2017-05-08 15:30:03 +02:00
.TP
2023-07-01 12:15:55 +02:00
.B "\-f"
the same as -n, consistent with other crond implementations.
.TP
2017-05-08 15:30:03 +02:00
.B "\-p"
2019-08-06 18:08:05 +02:00
Allows
2017-05-08 15:30:03 +02:00
.I Cron
to accept any user set crontables.
.TP
2019-08-06 18:08:05 +02:00
.B "\-P"
Don't set PATH. PATH is instead inherited from the environment.
.TP
2017-05-08 15:30:03 +02:00
.B "\-c"
This option enables clustering support, as described below.
.TP
.B "\-s"
2019-08-06 18:08:05 +02:00
This option will direct
2017-05-08 15:30:03 +02:00
.I Cron
to send the job output to the system log using
2019-08-06 18:08:05 +02:00
.BR syslog (3).
2017-05-08 15:30:03 +02:00
This is useful if your system does not have
.BR sendmail (8),
installed or if mail is disabled.
.TP
.B "\-x"
2019-08-06 18:08:05 +02:00
This option allows you to set debug flags.
.TP
.B "\-V"
Print version and exit.
2017-05-08 15:30:03 +02:00
.SH SIGNALS
2019-08-06 18:08:05 +02:00
When the
.I SIGHUP
is received, the
.I Cron
daemon will close and reopen its log file. This proves to be useful in
scripts which rotate and age log files. Naturally, this is not relevant
if
2017-05-08 15:30:03 +02:00
.I Cron
was built to use
.IR syslog (3).
.SH CLUSTERING SUPPORT
In this version of
.IR Cron
it is possible to use a network-mounted shared
2019-08-06 18:08:05 +02:00
.I /var/spool/cron
2017-05-08 15:30:03 +02:00
across a cluster of hosts and specify that only one of the hosts should
2019-08-06 18:08:05 +02:00
run the crontab jobs in this directory at any one time. This is done by
starting
2017-05-08 15:30:03 +02:00
.I Cron
2019-08-06 18:08:05 +02:00
with the
.B \-c
option, and have the
2017-05-08 15:30:03 +02:00
.I /var/spool/cron/.cron.hostname
2019-08-06 18:08:05 +02:00
file contain just one line, which represents the hostname of whichever
host in the cluster should run the jobs. If this file does not exist, or
the hostname in it does not match that returned by
.BR gethostname (2),
then all crontab files in this directory are ignored. This has no effect
on cron jobs specified in the
2017-05-08 15:30:03 +02:00
.I /etc/crontab
file or on files in the
.I /etc/cron.d
2019-08-06 18:08:05 +02:00
directory. These files are always run and considered host-specific.
2017-05-08 15:30:03 +02:00
.PP
Rather than editing
.I /var/spool/cron/.cron.hostname
2019-08-06 18:08:05 +02:00
directly, use the
.B \-n
option of
2017-05-08 15:30:03 +02:00
.BR crontab (1)
to specify the host.
.PP
2019-08-06 18:08:05 +02:00
You should ensure that all hosts in a cluster, and the file server from
which they mount the shared crontab directory, have closely synchronised
clocks, e.g., using
.BR ntpd (8),
otherwise the results will be very unpredictable.
2017-05-08 15:30:03 +02:00
.PP
2019-08-06 18:08:05 +02:00
Using cluster sharing automatically disables inotify support, because
inotify cannot be relied on with network-mounted shared file systems.
2017-05-08 15:30:03 +02:00
.SH CAVEATS
All
.BR crontab
2019-08-06 18:08:05 +02:00
files have to be regular files or symlinks to regular files, they must
not be executable or writable for anyone else but the owner. This
requirement can be overridden by using the
.B \-p
option on the crond command line. If inotify support is in use, changes
in the symlinked crontabs are not automatically noticed by the cron
daemon. The cron daemon must receive a SIGHUP signal to reload the
crontabs. This is a limitation of the inotify API.
2017-05-08 15:30:03 +02:00
.PP
2019-08-06 18:08:05 +02:00
The syslog output will be used instead of mail, when sendmail is not
installed.
2017-05-08 15:30:03 +02:00
.SH "SEE ALSO"
.BR crontab (1),
.BR crontab (5),
.BR inotify (7),
.BR pam (8)
.SH AUTHOR
2019-08-06 18:08:05 +02:00
.MT vixie@isc.org
Paul Vixie
.ME
.br
.MT mmaslano@redhat.com
Marcela Mašláňová
.ME
.br
.MT colin@colin-dean.org
Colin Dean
.ME
.br
.MT tmraz@fedoraproject.org
Tomáš Mráz
.ME