Import Upstream version 1.7.2

This commit is contained in:
geos_one
2025-08-06 17:45:07 +02:00
commit 8035530473
75 changed files with 33406 additions and 0 deletions

16
man/Makemodule.am Normal file
View File

@@ -0,0 +1,16 @@
dist_man_MANS = \
man/cron.8 \
man/crond.8 \
man/cronnext.1 \
man/crontab.1 \
man/crontab.5
anacron_man = \
man/anacrontab.5 \
man/anacron.8
EXTRA_DIST += $(anacron_man)
if ANACRON
dist_man_MANS += $(anacron_man)
endif

217
man/anacron.8 Normal file
View File

@@ -0,0 +1,217 @@
.TH ANACRON 8 2012-11-22 "cronie" "System Administration"
.SH NAME
anacron \- runs commands periodically
.SH SYNOPSIS
.B anacron \fR[\fB-s\fR] [\fB-f\fR] [\fB-n\fR] [\fB-d\fR] [\fB-q\fR]
[\fB-t anacrontab\fR] [\fB-S spooldir\fR] [\fIjob\fR]
.br
.B anacron \fR[\fB-S spooldir\fR] -u [\fB-t anacrontab\fR] \fR[\fIjob\fR]
.br
.B anacron \fR[\fB-V\fR|\fB-h\fR]
.br
.B anacron -T \fR[\fB-t anacrontab\fR]
.SH DESCRIPTION
.B Anacron
is used to execute commands periodically, with a frequency specified in
days. Unlike
.BR cron(8) ,
it does not assume that the machine is running continuously. Hence, it
can be used on machines that are not running 24 hours a day to control
regular jobs as daily, weekly, and monthly jobs.
.PP
Anacron reads a list of jobs from the
.I /etc/anacrontab
configuration file (see
.BR anacrontab (5)).
This file contains the list of jobs that Anacron controls. Each job
entry specifies a period in days, a delay in minutes, a unique job
identifier, and a shell command.
.PP
For each job, Anacron checks whether this job has been executed in the
last
.B n
days, where
.B n
is the time period specified for that job. If a job has not been
executed in
.B n
days or more, Anacron runs the job's shell command, after waiting for the
number of minutes specified as the delay parameter.
.PP
After the command exits, Anacron records the date (excludes the hour) in
a special timestamp file for that job, so it knows when to execute that
job again.
.PP
When there are no more jobs to be run, Anacron exits.
.PP
Anacron only considers jobs whose identifier, as specified in
.BR anacrontab (5),
matches any of the
.I job
command-line arguments. The
.I job
command-line arguments can be represented by shell wildcard patterns (be
sure to protect them from your shell with adequate quoting). Specifying
no
.I job
command-line arguments is equivalent to specifying "*" (that is, all
jobs are considered by Anacron).
.PP
Unless Anacron is run with the
.B \-d
option (specified below), it forks to the background when it starts, and
any parent processes exit immediately.
.PP
Unless Anacron is run with the
.B \-s
or
.B \-n
options, it starts jobs immediately when their delay is over. The
execution of different jobs is completely independent.
.PP
If an executed job generates any output to standard output or to standard
error, the output is mailed to the user under whom Anacron is running
(usually root), or to the address specified in the
.B MAILTO
environment variable in the
.I /etc/anacrontab
file, if such exists. If the
.B LOGNAME
environment variable is set, it is used in the From: field of the mail.
.PP
Any informative messages generated by Anacron are sent to
.BR syslogd (8)
or
.BR rsyslogd (8)
under with facility set to
.B cron
and priority set to
.BR notice .
Any error messages are sent with the priority
.BR error .
.PP
"Active" jobs (i.e., jobs that Anacron already decided to run and are now
waiting for their delay to pass, and jobs that are currently being
executed by Anacron), are "locked", so that other copies of Anacron
cannot run them at the same time.
.SH OPTIONS
.TP
.B \-f
Forces execution of all jobs, ignoring any timestamps.
.TP
.B \-u
Updates the timestamps of all jobs to the current date, but does not run
any.
.TP
.B \-s
Serializes execution of jobs. Anacron does not start a new job before the
previous one finished.
.TP
.B \-n
Runs jobs immediately and ignores the specified delays in the
.I /etc/anacrontab
file. This options implies
.BR -s .
.TP
.B \-d
Does not fork Anacron to the background. In this mode, Anacron will
output informational messages to standard error, as well as to syslog.
The output of any job is mailed by Anacron.
.TP
.B \-q
Suppresses any messages to standard error. Only applicable with
.BR -d .
.TP
.B -t some_anacrontab
Uses the specified anacrontab, rather than the
.I /etc/anacrontab
default one.
.TP
.B -T
Anacrontab testing. Tests the
.I /etc/anacrontab
configuration file for validity. If there is an error in the file, it is
shown on the standard output and Anacron returns the value of 1. Valid
anacrontabs return the value of 0.
.TP
.B -S spooldir
Uses the specified spooldir to store timestamps in. This option is
required for users who wish to run anacron themselves.
.TP
.B -V
Prints version information, and exits.
.TP
.B -h
Prints short usage message, and exits.
.SH SIGNALS
After receiving a
.B SIGUSR1
signal, Anacron waits for any running jobs to finish and then exits.
This can be used to stop Anacron cleanly.
.SH NOTES
Make sure your time-zone is set correctly before Anacron is started since
the time-zone affects the date. This is usually accomplished by setting
the TZ environment variable, or by installing a
.I /usr/lib/zoneinfo/localtime
file. See
.BR tzset (3)
for more information.
.PP
Timestamp files are created in the spool directory for each job specified
in an anacrontab. These files are never removed automatically by
Anacron, and should be removed by hand if a job is no longer being
scheduled.
.SH FILES
.TP
.I /etc/anacrontab
Contains specifications of jobs. See
.BR anacrontab (5)
for a complete description.
.TP
.I /var/spool/anacron
This directory is used by Anacron for storing timestamp files.
.SH "SEE ALSO"
.BR anacrontab (5),
.BR cron (8),
.BR tzset (3)
.PP
The Anacron
.I README
file.
.SH BUGS
Anacron never removes timestamp files. Remove unused files manually.
.PP
Anacron uses up to two file descriptors for each active job. It may run
out of descriptors if there are lots of active jobs. See
.B echo $(($(ulimit -n) / 2))
for information how many concurrent jobs anacron may run.
.PP
Mail comments, suggestions and bug reports to
.MT shaleh@\:(debian.\:org|\:valinux.\:com)
Sean 'Shaleh' Perry
.ME .
.SH AUTHOR
Anacron was originally conceived and implemented by
.MT schwarz@\:monet.\:m.\:isar.\:de
Christian Schwarz
.ME .
.PP
The current implementation is a complete rewrite by
.MT itzur@\:actcom.\:co.\:il
Itai Tzur
.ME .
.PP
The code base was maintained by
.MT shaleh@\:(debian.\:org|\:valinux.\:com)
Sean 'Shaleh' Perry
.ME .
.PP
Since 2004, it is maintained by
.MT pasc@\:(debian.\:org|\:redellipse.\:net)
Pascal Hakim
.ME .
.PP
For Fedora, Anacron is maintained by
.MT mmaslano@redhat.\:com
Marcela Mašláňová
.ME .

145
man/anacrontab.5 Normal file
View File

@@ -0,0 +1,145 @@
.TH ANACRONTAB 5 2012-11-22 "cronie" "File Formats"
.SH NAME
/etc/anacrontab \- configuration file for Anacron
.SH DESCRIPTION
The
.I /etc/anacrontab
configuration file describes the jobs controlled by
.BR anacron (8).
It can contain three types of lines: job-description lines, environment
assignments, or empty lines.
.PP
Job-description lines can have the following format:
.PP
period in days delay in minutes job-identifier command
.PP
The
.I period in days
variable specifies the frequency of execution of a job in days. This
variable can be represented by an integer or a macro (@daily, @weekly,
@monthly), where @daily denotes the same value as the integer 1, @weekly
the same as 7, and @monthly specifies that the job is run once a month,
independent on the length of the month.
.PP
The
.I delay in minutes
variable specifies the number of minutes anacron waits, if necessary,
before executing a job. This variable is represented by an integer where
0 means no delay.
.PP
The
.I job-identifier
variable specifies a unique name of a job which is used in the log files.
.PP
The
.I command
variable specifies the command to execute. The command can either be a
command such as
.B ls /proc >> /tmp/proc
or a command to execute a custom script.
.PP
Environment assignment lines can have the following format:
.PP
VAR=VALUE
.PP
Any spaces around
.I VAR
are removed. No spaces around
.I VALUE
are allowed (unless you want them to be part of the value). The
specified assignment takes effect from the next line until the end of the
file, or to the next assignment of the same variable.
.PP
The
.I START_HOURS_RANGE
variable defines an interval (in hours) when scheduled jobs can be run.
In case this time interval is missed, for example, due to a power down,
then scheduled jobs are not executed that day.
.PP
The
.I RANDOM_DELAY
variable denotes the maximum number of minutes that will be added to the
delay in minutes variable which is specified for each job. A
.I RANDOM_DELAY
set to 12 would therefore add, randomly, between 0 and 12 minutes to the
delay in minutes for each job in that particular anacrontab. When set to
0, no random delay is added.
.PP
If
.I MAILTO
is defined (and non-empty), mail is sent to the specified address,
otherwise, system user is used.
.PP
If
.I MAILFROM
is defined (and non-empty), it is used as the envelope sender address,
otherwise, system user is used.
.PP
(Note: Both
.I MAILFROM
and
.I MAILTO
variables are expanded, so setting them as in the following example works as expected: MAILFROM=cron-$USER@cron.com ($USER is replaced by the system user) )
.PP
If
.I NO_MAIL_OUTPUT
is defined (and non-empty), the standard output and error descriptors of job processes are not redirected and e-mailed.
.PP
.PP
Empty lines are either blank lines, line containing white spaces only, or
lines with white spaces followed by a '#' followed by an arbitrary
comment.
.PP
You can continue a line onto the next line by adding a '\\' at the end of it.
.PP
In case you want to disable Anacron, add a line with
.I 0anacron
which is the name of the script running the Anacron into the
.I /etc/cron.hourly/jobs.deny
file.
.SH EXAMPLE
This example shows how to set up an Anacron job similar in functionality to
.I /etc/crontab
which starts all regular jobs
between 6:00 and 8:00
.I only.
A
.I RANDOM_DELAY
which can be 30 minutes at the most is specified. Jobs will run
serialized in a queue where each job is started only after the previous
one is finished.
.PP
.nf
# environment variables
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
RANDOM_DELAY=30
# Anacron jobs will start between 6am and 8am.
START_HOURS_RANGE=6-8
# delay will be 5 minutes + RANDOM_DELAY for cron.daily
1 5 cron.daily nice run-parts /etc/cron.daily
7 0 cron.weekly nice run-parts /etc/cron.weekly
@monthly 0 cron.monthly nice run-parts /etc/cron.monthly
.fi
.SH "SEE ALSO"
.BR anacron (8),
.BR crontab (1)
.PP
The Anacron
.I README
file.
.SH AUTHOR
.MT itzur@\:actcom.\:co.\:il
Itai Tzur
.ME
.PP
Currently maintained by
.MT pasc@\:(debian.\:org|\:redellipse.\:net)
Pascal Hakim
.ME .
.PP
For Fedora, maintained by
.MT mmaslano@redhat.com
Marcela Mašláňová
.ME .

285
man/cron.8 Normal file
View File

@@ -0,0 +1,285 @@
.\"/* Copyright 1988,1990,1993,1996 by Paul Vixie
.\" * All rights reserved
.\" */
.\"
.\" 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 $
.\"
.TH CRON "8" "2013-09-26" "cronie" "System Administration"
.SH NAME
crond \- daemon to execute scheduled commands
.SH SYNOPSIS
.B crond
.RB [ -c " | " -h " | " -i " | " -n " | " -p " | " -P " | " -s " | " -m \fP\fI<mail command>\fP ]
.br
.B crond
.B -x
.RB [ext,sch,proc,pars,load,misc,test,bit]
.br
.B crond
.B -V
.SH DESCRIPTION
.I Cron
is started from
.I /etc/rc.d/init.d
or
.I /etc/init.d
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.
.PP
.I Cron
searches
.I /var/spool/cron
for crontab files which are named after accounts in
.I /etc/passwd;
The found crontabs are loaded into the memory.
.I Cron
also searches for
.I /etc/anacrontab
and any files in the
.I /etc/cron.d
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
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
.B "\-s"
option.
.PP
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
.I /var/log/cron
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.
.PP
When using the modtime option,
.I Cron
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.
.PP
.I Cron
checks these files and directories:
.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
.IR /etc/anacrontab
configuration file. See
.BR anacrontab (5)
for more details.
.TP
.IR /etc/cron.d/
directory that contains system cronjobs stored for different users.
.TP
.IR /var/spool/cron
directory that contains user crontables created by the
.IR crontab
command.
.PP
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
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.
.PP
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.
.PP
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.
.PP
It is possible to use different time zones for crontables. See
.BR crontab (5)
for more information.
.SS PAM Access Control
.IR Cron
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
.IR /etc/pam.d/crond .
The daemon loads the PAM environment from the pam_env module. This can
be overridden by defining specific settings in the appropriate crontab
file.
.SH "OPTIONS"
.TP
.B "\-h"
Prints a help message and exits.
.TP
.B "\-i"
Disables inotify support.
.TP
.B "\-m"
This option allows you to specify a shell command to use for sending
.I Cron
mail output instead of using
.BR sendmail (8)
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)
will disable the sending of mail.
.TP
.B "\-n"
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.
.TP
.B "\-f"
the same as -n, consistent with other crond implementations.
.TP
.B "\-p"
Allows
.I Cron
to accept any user set crontables.
.TP
.B "\-P"
Don't set PATH. PATH is instead inherited from the environment.
.TP
.B "\-c"
This option enables clustering support, as described below.
.TP
.B "\-s"
This option will direct
.I Cron
to send the job output to the system log using
.BR syslog (3).
This is useful if your system does not have
.BR sendmail (8)
installed or if mail is disabled.
.TP
.B "\-x"
This option allows you to set debug flags.
.TP
.B "\-V"
Print version and exit.
.SH SIGNALS
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
.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
.I /var/spool/cron
across a cluster of hosts and specify that only one of the hosts should
run the crontab jobs in this directory at any one time. This is done by
starting
.I Cron
with the
.B \-c
option, and have the
.I /var/spool/cron/.cron.hostname
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
.I /etc/crontab
file or on files in the
.I /etc/cron.d
directory. These files are always run and considered host-specific.
.PP
Rather than editing
.I /var/spool/cron/.cron.hostname
directly, use the
.B \-n
option of
.BR crontab (1)
to specify the host.
.PP
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.
.PP
Using cluster sharing automatically disables inotify support, because
inotify cannot be relied on with network-mounted shared file systems.
.SH CAVEATS
All
.BR crontab
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.
.PP
The syslog output will be used instead of mail, when sendmail is not
installed.
.SH "SEE ALSO"
.BR crontab (1),
.BR crontab (5),
.BR inotify (7),
.BR pam (8)
.SH AUTHOR
.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

1
man/crond.8 Normal file
View File

@@ -0,0 +1 @@
.so man8/cron.8

86
man/cronnext.1 Normal file
View File

@@ -0,0 +1,86 @@
.TH CRONNEXT 1 "2017-06-11" "cronie" "User Commands"
.SH NAME
cronnext \- time of next job cron will execute
.SH SYNOPSIS
.TP 9
.B cronnext
[\fB-i \fIusers\fR] [\fB-e \fIusers\fR] [\fB-s\fR]
[\fB-a\fR]
[\fB-t \fItime\fR] [\fB-q \fItime\fR] [\fB-j \fIcommand\fR]
[\fB-l\fR] [\fB-c\fR] [\fB-f\fR] [\fB-h\fR] [\fB-V\fR]
[file]...
.SH DESCRIPTION
Determine the time cron will execute the next job. Without arguments, it
prints that time considering all crontabs, in number of seconds since the
Epoch, rounded to the minute. This number can be converted into other formats
using
.BR date (1),
like
.B date --date @43243254
The file arguments are optional. If provided,
.I cronnext
uses them as crontabs instead of the ones installed in the system.
.SH OPTIONS
.TP
.BI "\-i " user,user,user,...
Consider only the crontabs of the specified users. Use
.B *system*
for the system crontab.
.TP
.BI "\-e " user,user,user,...
Do not consider the crontabs of the specified users.
.TP
.B \-s
Do not consider the system crontab, usually the
.I /etc/crontab
file. The system crontab usually contains the hourly, daily, weekly and
monthly crontabs, which might be better dealt with
.BR anacron (8).
.TP
.BI \-a
Use the crontabs installed in the system in addition to the ones passed as
file arguments. This is implicit if no file is passed.
.TP
.BI "\-t " time
Determine the next job from this time, instead of now. The time is
expressed in number of seconds since the Epoch, as obtained for example by
.BR "date +%s --date \(dqnow + 2 hours\(dq" ,
and is internally rounded to the minute.
.TP
.BI "\-q " time
Do not check jobs over this time, expressed in the same way as in option
.BR -t .
.TP
.BI "\-j " command
Only look for jobs that contain \fIcommand\fP as a substring.
.TP
.B \-l
Print the whole entries of the jobs that are the next to be executed by cron.
The default is to only print their next time of execution.
.TP
.B \-c
Print every entry in every crontab with the next time it is executed.
.TP
.B \-f
Print all jobs that are executed in the given interval. Requires option
\fB-q\fR.
.TP
.B \-h
Print usage output and exit.
.TP
.B \-V
Print version and exit.
.SH AUTHOR
.MT sgerwk@aol.com
Marco Migliori
.ME
.SH SEE ALSO
.BR cron (8),
.BR cron (1),
.BR crontab (5),
.BR crontab (1),
.BR anacron (8),
.BR anacrontab (5),
.BR atq (1),
.BR date (1)

264
man/crontab.1 Normal file
View File

@@ -0,0 +1,264 @@
.\"/* Copyright 1988,1990,1993 by Paul Vixie
.\" * All rights reserved
.\" */
.\"
.\" 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: crontab.1,v 1.7 2004/01/23 19:03:32 vixie Exp $
.\"
.TH CRONTAB 1 "2019-10-29" "cronie" "User Commands"
.SH NAME
crontab \- maintains crontab files for individual users
.SH SYNOPSIS
.B crontab
.RB [ -u
.IR user ]
.RI < "file"
.RB | \ - >
.br
.B crontab
.RB [ -T ]
.RI < "file"
.RB | \ - >
.br
.B crontab
.RB [ -u
.IR user ]
.RB < -l " | " -r " | " -e >\ [ -i ]
.RB [ -s ]
.br
.B crontab
.BR -n \ [
.IR "hostname " ]
.br
.B crontab
.BR -c
.br
.B crontab
.BR -V
.SH DESCRIPTION
.I Crontab
is the program used to install a crontab table
.IR file ,
remove or list the existing tables used to serve the
.BR cron (8)
daemon. Each user can have their own crontab, and though these are files
in
.IR /var/spool/ ,
they are not intended to be edited directly. For SELinux in MLS mode,
you can define more crontabs for each range. For more information, see
.BR selinux (8).
.PP
In this version of
.IR Cron
it is possible to use a network-mounted shared
.I /var/spool/cron
across a cluster of hosts and specify that only one of the hosts should
run the crontab jobs in the particular directory at any one time. You
may also use
.BR crontab
from any of these hosts to edit the same shared set of crontab files, and
to set and query which host should run the crontab jobs.
.PP
Scheduling cron jobs with
.BR crontab
can be allowed or disallowed for different users. For this purpose, use the
.I cron.allow
and
.I cron.deny
files. If the
.I cron.allow
file exists, a user must be listed in it to be allowed to use
.BR crontab .
If the
.I cron.allow
file does not exist but the
.I cron.deny
file does exist, then a user must
.I not
be listed in the
.I cron.deny
file in order to use
.BR crontab.
If neither of these files exist, then only the super user is allowed to use
.BR crontab .
.PP
Another way to restrict the scheduling of cron jobs beyond
.BR crontab
is to use PAM authentication in
.I /etc/security/access.conf
to set up users, which are allowed or disallowed to use
.BR crontab
or modify system cron jobs in the
.IR /etc/cron.d/
directory.
.PP
The temporary directory can be set in an environment variable. If it is
not set by the user, the
.I /tmp
directory is used.
.PP
When listing a crontab on a terminal the output will be colorized unless
an environment variable
.I NO_COLOR
is set.
.PP
On edition or deletion of the crontab, a backup of the last crontab will be saved to
.I $XDG_CACHE_HOME/crontab/crontab.bak
or
.I $XDG_CACHE_HOME/crontab/crontab.<user>.bak
if
.B -u
is used.
If the
.I XDG_CACHE_HOME
environment variable is not set,
.I $HOME/.cache
will be used instead.
.PP
.SH "OPTIONS"
.TP
.B "\-u"
Specifies the name of the user whose crontab is to be modified. If this
option is not used,
.BR crontab
examines "your" crontab, i.e., the crontab of the person executing the
command. If no crontab exists for a particular user, it is created for
them the first time the
.B crontab -u
command is used under their username.
.TP
.B "\-T"
Test the crontab file syntax without installing it.
Once an issue is found, the validation is interrupted, so this will not return all the existing issues at the same execution.
.TP
.B "\-l"
Displays the current crontab on standard output.
.TP
.B "\-r"
Removes the current crontab.
.TP
.B "\-e"
Edits the current crontab using the editor specified by the
.I VISUAL
or
.I EDITOR
environment variables. After you exit from the editor, the modified
crontab will be installed automatically.
.TP
.B "\-i"
This option modifies the
.B "\-r"
option to prompt the user for a 'y/Y' response before actually removing
the crontab.
.TP
.B "\-s"
Appends the current SELinux security context string as an MLS_LEVEL
setting to the crontab file before editing / replacement occurs - see the
documentation of MLS_LEVEL in
.BR crontab (5).
.TP
.B "\-n"
This option is relevant only if
.BR cron (8)
was started with the
.B \-c
option, to enable clustering support. It is used to set the host in the
cluster which should run the jobs specified in the crontab files in the
.I /var/spool/cron
directory. If a hostname is supplied, the host whose hostname returned
by
.BR gethostname (2)
matches the supplied hostname, will be selected to run the selected cron jobs subsequently. If there
is no host in the cluster matching the supplied hostname, or you explicitly specify
an empty hostname, then the selected jobs will not be run at all. If the hostname
is omitted, the name of the local host returned by
.BR gethostname (2)
is used. Using this option has no effect on the
.I /etc/crontab
file and the files in the
.I /etc/cron.d
directory, which are always run, and considered host-specific. For more
information on clustering support, see
.BR cron (8).
.TP
.B "\-c"
This option is only relevant if
.BR cron (8)
was started with the
.B \-c
option, to enable clustering support. It is used to query which host in
the cluster is currently set to run the jobs specified in the crontab
files in the directory
.I /var/spool/cron
, as set using the
.B \-n
option.
.TP
.B "\-V"
Print version and exit.
.SH CAVEATS
The files
.I cron.allow
and
.I cron.deny
cannot be used to restrict the execution of cron jobs; they only restrict the
use of
.BR crontab .
In particular, restricting access to
.BR crontab
has no effect on an existing
.I crontab
of a user. Its jobs will continue to be executed until the crontab is removed.
.PP
The files
.I cron.allow
and
.I cron.deny
must be readable by the user invoking
.BR crontab .
If this is not the case, then they are treated as non-existent.
.SH "SEE ALSO"
.BR crontab (5),
.BR cron (8)
.SH FILES
.nf
/etc/cron.allow
/etc/cron.deny
.fi
.SH STANDARDS
The
.I crontab
command conforms to IEEE Std1003.2-1992 (``POSIX'') with one exception:
For replacing the current crontab with data from standard input the
.B \-
has to be specified on the command line if the standard input is a TTY.
This new command syntax differs from previous versions of Vixie Cron,
as well as from the classic SVR3 syntax.
.SH DIAGNOSTICS
An informative usage message appears if you run a crontab with a faulty
command defined in it.
.SH AUTHOR
.MT vixie@isc.org
Paul Vixie
.ME
.br
.MT colin@colin-dean.org
Colin Dean
.ME

375
man/crontab.5 Normal file
View File

@@ -0,0 +1,375 @@
.\"/* Copyright 1988,1990,1993,1994 by Paul Vixie
.\" * All rights reserved
.\" */
.\"
.\" 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.
.\"
.\" $Id: crontab.5,v 1.6 2004/01/23 19:03:33 vixie Exp $
.\"
.TH CRONTAB 5 2012-11-22 "cronie" "File Formats"
.SH NAME
crontab \- files used to schedule the execution of programs
.SH DESCRIPTION
A
.I crontab
file contains instructions for the
.BR cron (8)
daemon in the following simplified manner: "run this command at this time
on this date". Each user can define their own crontab. Commands defined
in any given crontab are executed under the user who owns that particular
crontab. Uucp and News usually have their own crontabs, eliminating the
need for explicitly running
.BR su (1)
as part of a cron command.
.PP
Blank lines, leading spaces, and tabs are ignored. Lines whose first
non-white space character is a pound-sign (#) are comments, and are not
processed. Note that comments are not allowed on the same line as cron
commands, since they are considered a part of the command. Similarly,
comments are not allowed on the same line as environment variable
settings.
.PP
An active line in a crontab is either an environment setting or a cron
command. An environment setting is of the form:
.PP
name = value
.PP
where the white spaces around the equal-sign (=) are optional, and any
subsequent non-leading white spaces in
.I value
is a part of the value assigned to
.IR name .
The
.I value
string may be placed in quotes (single or double, but matching) to
preserve leading or trailing white spaces.
.PP
Several environment variables are set up automatically by the
.BR cron (8)
daemon.
.I SHELL
is set to /bin/sh, and
.I LOGNAME
and
.I HOME
are set from the /etc/passwd line of the crontab\'s owner.
.I HOME
and
.I SHELL
can be overridden by settings in the crontab; LOGNAME can not.
.PP
(Note: the
.I LOGNAME
variable is sometimes called
.I USER
on BSD systems and is also automatically set).
.PP
In addition to
.IR LOGNAME ,
.IR HOME ,
and
.IR SHELL ,
.BR cron (8)
looks at the
.I MAILTO
variable if a mail needs to be send as a result of running any commands
in that particular crontab. If
.I MAILTO
is defined (and non-empty), mail is sent to the specified address. If
.I MAILTO
is defined but empty
.RI ( MAILTO="" ),
no mail is sent. Otherwise, mail is sent to the owner of the crontab.
This option is useful if you decide to use /bin/mail instead of
/usr/lib/sendmail as your mailer. Note that /bin/mail does not provide
aliasing and UUCP usually does not read its mail. If
.I MAILFROM
is defined (and non-empty), it is used as the envelope sender address,
otherwise, the username of the executing user is used. This variable is
also inherited from the crond process environment.
.PP
(Note: Both
.I MAILFROM
and
.I MAILTO
variables are expanded, so setting them as in the following example works as expected: MAILFROM=cron-$USER@cron.com ($USER is replaced by the system user) )
.PP
By default, cron sends a mail using the 'Content-Type:' header
of 'text/plain' with the 'charset=' parameter set to the 'charmap/codeset'
of the locale in which
.BR crond (8)
is started up, i.e., either the default system locale, if no LC_*
environment variables are set, or the locale specified by the LC_*
environment variables (see
.BR locale (7)).
Different character encodings can be used for mailing cron job outputs by
setting the
.I CONTENT_TYPE
and
.I CONTENT_TRANSFER_ENCODING
variables in a crontab to the correct values of the mail headers of those
names.
.PP
The
.I CRON_TZ
variable specifies the time zone specific for the cron table. The user
should enter a time according to the specified time zone into the table.
The time used for writing into a log file is taken from the local time
zone, where the daemon is running.
.PP
The
.I MLS_LEVEL
environment variable provides support for multiple per-job SELinux
security contexts in the same crontab. By default, cron jobs execute
with the default SELinux security context of the user that created the
crontab file. When using multiple security levels and roles, this may
not be sufficient, because the same user may be running in different
roles or in different security levels. For more information about roles
and SELinux MLS/MCS, see
.BR selinux (8)
and the crontab example mentioned later on in this text. You can set the
.I MLS_LEVEL
variable to the SELinux security context string specifying the particular
SELinux security context in which you want jobs to be run.
.B crond
will then set the execution context of those jobs that meet the
specifications of the particular security context. For more information,
see
.BR crontab (1)\ -s\ option.
.PP
The
.I RANDOM_DELAY
variable allows delaying job startups by random amount of minutes with
upper limit specified by the variable. The random scaling factor is
determined during the cron daemon startup so it remains constant for
the whole run time of the daemon.
.PP
The format of a cron command is similar to the V7 standard, with a number
of upward-compatible extensions. Each line has five time-and-date fields
followed by a
.BR user name
(if this is the
.BR system
crontab file), and followed by a command. Commands are executed by
.BR cron (8)
when the 'minute', 'hour', and 'month of the year' fields match the
current time,
.I and
at least one of the two 'day' fields ('day of month', or 'day of week')
match the current time (see "Note" below).
.PP
Note that this means that non-existent times, such as the "missing hours"
during the daylight savings time conversion, will never match, causing
jobs scheduled during the "missing times" not to be run. Similarly,
times that occur more than once (again, during the daylight savings time
conversion) will cause matching jobs to be run twice.
.PP
.BR cron (8)
examines cron entries every minute.
.PP
The time and date fields are:
.IP
.ta 1.5i
field allowed values
.br
----- --------------
.br
minute 0-59
.br
hour 0-23
.br
day of month 1-31
.br
month 1-12 (or names, see below)
.br
day of week 0-7 (0 or 7 is Sunday, or use names)
.br
.PP
A field may contain an asterisk (*), which always stands for
"first\-last".
.PP
Ranges of numbers are allowed. Ranges are two numbers separated with a
hyphen. The specified range is inclusive. For example, 8-11 for
an 'hours' entry specifies execution at hours 8, 9, 10, and 11. The first
number must be less than or equal to the second one.
.PP
Randomization of the execution time within a range can be used.
A random number within a range specified as two numbers separated with
a tilde is picked. The specified range is inclusive.
For example, 6~15 for a 'minutes' entry picks a random minute
within 6 to 15 range. The random number is picked when crontab file is parsed.
The first number must be less than or equal to the second one. You might omit
one or both of the numbers specifying the range. For example, ~ for a 'minutes'
entry picks a random minute within 0 to 59 range.
.PP
Lists are allowed. A list is a set of numbers (or ranges) separated by
commas. Examples: "1,2,5,9", "0-4,8-12".
.PP
Step values can be used in conjunction with ranges. Following a range
with "/<number>" specifies skips of the number's value through the range.
For example, "0-23/2" can be used in the 'hours' field to specify command
execution for every other hour (the alternative in the V7 standard is
"0,\:2,\:4,\:6,\:8,\:10,\:12,\:14,\:16,\:18,\:20,\:22"). Step values are
also permitted after an asterisk, so if specifying a job to be run every
two hours, you can use "*/2". Please note that steps are evaluated just
within the field they are applied to. For example "*/23" in hours field
means to execute the job on the hour 0 and the hour 23 within a calendar
day. See "NOTES" below for a workaround.
.PP
Names can also be used for the 'month' and 'day of week' fields. Use the
first three letters of the particular day or month (case does not
matter). Ranges and lists of names are allowed. Examples: "mon,wed,fri",
"jan-mar".
.PP
If the UID of the owner is 0 (root), the first character of a crontab
entry can be "-" character. This will prevent cron from writing a syslog
message about the command being executed.
.PP
The "sixth" field (the rest of the line) specifies the command to be run.
The entire command portion of the line, up to a newline or a "%"
character, will be executed by /bin/sh or by the shell specified in the
SHELL variable of the cronfile. A "%" character in the command, unless
escaped with a backslash (\\), will be changed into newline characters,
and all data after the first % will be sent to the command as standard
input.
.PP
Note: The day of a command's execution can be specified in the following
two fields \(em 'day of month', and 'day of week'. If both fields are
restricted (i.e., do not contain the "*" character), the command will be
run when
.I either
field matches the current time. For example,
.br
"30 4 1,15 * 5" would cause a command to be run at 4:30 am on the 1st and
15th of each month, plus every Friday.
.PP
A crontab file syntax can be tested before an install using the -T option. See
.BR crontab (1)
for details.
.SH EXAMPLE CRON FILE
.nf
# use /bin/sh to run commands, no matter what /etc/passwd says
SHELL=/bin/sh
# mail any output to `paul', no matter whose crontab this is
MAILTO=paul
#
CRON_TZ=Japan
# run five minutes after midnight, every day
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
# run at 2:15pm on the first of every month -- output mailed to paul
15 14 1 * * $HOME/bin/monthly
# run at 10 pm on weekdays, annoy Joe
0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
5 4 * * sun echo "run at 5 after 4 every sunday"
.fi
.SH Jobs in /etc/cron.d/
The jobs in
.I cron.d
and
.I /etc/crontab
are system jobs, which are used usually for more than one user, thus,
additionally the username is needed. MAILTO on the first line is
optional.
.SH EXAMPLE OF A JOB IN /etc/cron.d/job
.nf
#login as root
#create job with preferred editor (e.g. vim)
MAILTO=root
* * * * * root touch /tmp/file
.fi
.SH NOTES
As noted above, skip values only operate within the time period they\'re
attached to. For example, specifying "0/35" for the minute field of a
crontab entry won\'t cause that entry to be executed every 35 minutes;
instead, it will be executed twice every hour, at 0 and 35 minutes past.
For more fine-grained control you can do something like this:
.nf
* * * * * if [ $(expr \\( $(date +%s) / 60 \\) % 58) = 0 ]; then echo this runs every 58 minutes; fi
0 * * * * if [ $(expr \\( $(date +%s) / 3600 \\) % 23) = 0 ]; then echo this runs every 23 hours on the hour; fi
.fi
Adjust as needed if your
.BR date (1)
command does not accept "+%s" as the format string specifier to output
the current UNIX timestamp.
.SH SELinux with multi level security (MLS)
In a crontab, it is important to specify a security level by
.I crontab \-s
or specifying the required level on the first line of the crontab. Each
level is specified in
.IR /etc/selinux/targeted/seusers .
When using crontab in the MLS mode, it is especially important to:
.br
- check/change the actual role,
.br
- set correct
.I role for
.IR directory ,
which is used for input/output.
.SH EXAMPLE FOR SELINUX MLS
.nf
# login as root
newrole -r sysadm_r
mkdir /tmp/SystemHigh
chcon -l SystemHigh /tmp/SystemHigh
crontab -e
# write in crontab file
MLS_LEVEL=SystemHigh
0-59 * * * * id -Z > /tmp/SystemHigh/crontest
.fi
.SH FILES
.I /etc/crontab
main system crontab file.
.I /var/spool/cron/
a directory for storing crontabs defined by users.
.I /etc/cron.d/
a directory for storing system crontabs.
.SH "SEE ALSO"
.BR cron (8),
.BR crontab (1)
.SH EXTENSIONS
These special time specification "nicknames" which replace the 5 initial
time and date fields, and are prefixed with the '@' character, are
supported:
.PP
.nf
@reboot : Run once after reboot.
@yearly : Run once a year, ie. "0 0 1 1 *".
@annually : Run once a year, ie. "0 0 1 1 *".
@monthly : Run once a month, ie. "0 0 1 * *".
@weekly : Run once a week, ie. "0 0 * * 0".
@daily : Run once a day, ie. "0 0 * * *".
@hourly : Run once an hour, ie. "0 * * * *".
.fi
.SH CAVEATS
.BR crontab
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.
.PP
cron requires that each entry in a crontab end in a newline character. If the
last entry in a crontab is missing a newline (i.e.\& terminated by EOF),
cron will consider the crontab (at least partially) broken.
A warning will be written to syslog.
.SH AUTHOR
.MT vixie@isc.org
Paul Vixie
.ME