cron Daemon

Purpose

Runs commands automatically.

Syntax

cron [ -f configurationfile ] [ -Q ]

Description

The cron daemon runs shell commands at specified dates and times. The following event types are scheduled by the cron daemon:

  • crontab command events
  • at command events
  • batch command events
  • sync subroutine events
  • ksh command events
  • csh command events

The way these events are handled is specified by the /var/adm/cron/queuedefs file.

Regularly scheduled commands can be specified according to instructions contained in the crontab files. You can submit your crontab file with the crontab command. Use the at command to submit commands that are to be run only once. Because the cron daemon never exits, it should be run only once.

The cron daemon examines crontab files and at command files only when the cron daemon is initialized. When you make changes to the crontab files using the crontab command, a message indicating the change is sent to the cron daemon. This eliminates the overhead of checking for new or changed files at regularly scheduled intervals.
Note: When a user is no longer available, the cron jobs for that user are no longer run. Even if the user eventually becomes available, cron events for that user are no longer queued. The cron daemon does not log the information about user availability to the cronlog file.

When the TZ environment variable is changed, either with the chtz command through SMIT, the cron daemon must be restarted. This enables the cron daemon to use the correct time zone and summer time change information for the new TZ environment variable.

Note:
  1. If you have a job that is scheduled to run between 1:00 a.m. and 2:00 a.m. on the day your time zone changes from daylight saving time to standard time, your job will run twice.
  2. If you have a job that is scheduled to run between 2:01 a.m. and 2:59 a.m. on the day your time zone changes from standard time to daylight saving time, your job will not run. You can change the time these jobs run, run them manually, or with until the following day to run them. The cron daemon does not need to be stopped. However, if changes are made to the TZ environment variable, kill the current cron daemon so that it automatically respawns and recognizes the new TZ setting.
  3. If you have a job that is scheduled to run at 2:00 a.m. on the day your time zone changes from standard time to daylight saving time, your job will run one second early.

The cron daemon reads the /etc/cronlog.conf configuration file provided by the user to log the information. If a configuration file has not been created, then the cron daemon creates a log of its activities in the /var/adm/cron/log file. The cron daemon reads the configuration file when it is activated and when it receives the hangup signal.

If the cron daemon is not able to create or open the user-specified logfile, then it creates a log of its activities in the /var/adm/cron/log file.

Flags

Item Description
-f ConfigurationFile Specifies an alternate configuration file.
-Q Quiet mode. If specified, -Q disables the cron logging. This parameter is valid for a user-configured log file as well as the default /var/adm/cron/log file. This option must follow the -f option (if -f is specified).

Security

Auditing Events

If the auditing subsystem is properly configured and is enabled, the cron daemon generates the following audit record (event) every time the command is run:

Event Information
CRON_Start Lists the name of each job, whether the job was initiated by an at or cron command, and the time the job started.
CRON_Finish Lists the user's name, process ID of the job, and the time the processing was completed.

Attention RBAC users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

Files

Item Description
/var/adm/cron/FIFO A named pipe that sends messages to the cron daemon when new jobs are submitted with the crontab or at commands.
/var/adm/cron Specifies the main cron daemon directory.
/var/adm/cron/log Default log file which specifies the accounting information for all the executed cron. Contains information like the owner, pid, start time, command, and the exit status of the cron job. Rotation is not performed on this file.
/etc/cronlog.conf Specifies the default cron configuration file for logging information.
/var/adm/cron/queuedefs      Specifies the cron daemon events file.
/var/spool/cron Specifies the spool area.
/usr Indicates directory kept open by the cron daemon.
/usr/bin Indicates directory kept open by the cron daemon.
/usr/lib Indicates directory kept open by the cron daemon.
/etc Indicates directory kept open by the cron daemon.
/tmp Indicates directory kept open by the cron daemon.

Configuration File

The configuration file informs the cron daemon where and how to log the information. Using the configuration file you can specify logfile names, size limits, rotation policies, compress and archive attributes.

If you do not use the -f flag, the cron daemon reads the default /etc/cronlog.conf configuration file.

If cron fails to open the configuration file, it continues with /var/adm/cron/log.

The cron daemon ignores blank lines and lines beginning with a # (pound sign).