cron daemon — Run commands at specified dates and times
Format
cron
Description
cron is a clock daemon that runs commands at specified dates and times. You can specify regularly scheduled commands as described in crontab. You can also submit jobs that are to be run only once using the at command. cron runs commands with priorities and limits set by the queuedefs file. cron uses the value from queuedefs to lower the priority for non-UID=0 users only. The priority is unchanged for UID=0 users.
cron only examines crontab files and at command files when initializing or when a file changes using crontab or at. This reduces the overhead of checking for new or changed files at regularly scheduled intervals.
The setuid bit for cron should never be set; however, it must be started by a user with appropriate privileges to issue the setuid call for any UID. Because cron never exits, it should only be run once, normally during the system initialization process. cron automatically forks and runs itself in the background, in a new shell session. cron uses the pid file to prevent more than one cron running at the same time.
When matching the date and time expressions given in crontab entries, cron uses the time zone in effect when the system started the daemon. As a result, you should ensure that the TZ environment variable is set at this time. For information about setting the TZ environment variable, see Format of the TZ environment variable. For at jobs, cron uses the value of TZ in effect when you submitted the job.
at, batch, and crontab submit jobs to cron; the data for those jobs can contain double-byte characters. When the jobs are executed, the data in the jobs are interpreted in the locale that cron is using. Because it is strongly recommended that cron be started in the POSIX locale, double-byte characters in the jobs may not be interpreted correctly. You can get around this by calling the setlocale() system call in the job itself.
- The MVS identity is set to the user's MVS identity.
- The UNIX real and effective UIDs are set to the user's real UID.
- SIGTERM
- Causes cron to exit. You can cause cron to
exit with the following command:
where pid is the cron's PID number. To find the cron's PID number, you can use:kill –TERM pid
ps -e | grep cron
- SIGUSR1
- Is sent by either at or crontab to indicate a new at job or an updated crontab entry. cron does not delete at jobs until they finish running. If the cron daemon is terminated while at jobs are running, cron runs them again when the daemon is restarted.
- SIGUSR2
- Writes internal cron queue information to the log file.
Queue `c' 5j2n15w:
queued 4, running 5, jobs 5
Next try for queued jobs 13 seconds
RUNNING: uid/gid: 0/512: pid 33554441: sleep 10000 RUNNING: uid/gid: 0/512:
pid 385875972: echo start; sleep 10000; echo end RUNNING: uid/gid: 0/512: pid
67108876: echo start; sleep 10000; echo end RUNNING: uid/gid: 0/512: pid
33554445: echo start; sleep 10000; echo end RUNNING: uid/gid: 0/512: pid
67108879: echo start; sleep 10000; echo end QUEUED: uid/gid: 0/512: echo Hello!
QUEUED: uid/gid: 0/512: echo start; sleep 10000; echo end
QUEUED: uid/gid: 0/512: echo Hello!
QUEUED: uid/gid: 0/512: echo start; sleep 10000; echo end
cron uses
a number of files in the /usr/lib/cron directory to determine
which users may and may not use the at and crontab commands.
- The file at.allow contains the list of users who have permission to use at.
- The file at.deny contains the list of users who do not have permission to use at.
- cron.allow contains the list of users who have permission to use crontab.
- cron.deny contains the list of users who do not have permission to use crontab.
Files
- /etc/mailx.rc
- Although cron does not use this file directly, cron may call mailx which uses this file for configuration settings. Specifically, for cron to deliver messages properly, this file should contain a valid setting for the mailx sendmail variable. This file is generally copied from /samples/mailx.rc.
- /usr/spool/cron
- The main cron directory.
- /usr/spool/cron/atjobs
- A directory containing at files.
- /usr/spool/cron/crontabs
- A directory containing crontab files.
- /usr/spool/cron/log
- A file that maintains a history of the commands being run. The systems administrator should truncate this file periodically.
- /usr/spool/cron/pid
- A file that cron uses to ensure that only one version of cron is currently running on the system. This file must be unique per system which is particularly important when you are setting up a sysplex. See the section in z/OS UNIX System Services Planning about customizing cron for a read-only file system.
- /usr/lib/cron/at.allow
- Contains a list of the users who can use the at command (one per line).
- /usr/lib/cron/at.deny
- Contains a list of the users who cannot use the at command (one per line).
- /usr/lib/cron/cron.allow
- Contains a list of the users who can use the crontab command (one per line).
- /usr/lib/cron/cron.deny
- Contains a list of the users who cannot use the crontab command (one per line).
- /usr/lib/cron/queuedefs
- The queue description file (see the description of queuedefs in queuedefs — Queue description for at, batch, and cron).
Related information
at, crontab, mailx
Format of the TZ environment variable explains how to set the local time zone with the TZ environment variable.
For more information about customizing cron, see the section on customizing the cron, uucp, and mail utilities for a read-only root file system in z/OS UNIX System Services Planning. Also see the section about customizing the cron and uucp utilities in z/OS UNIX System Services Planning.