9.5 Refreshing a Daemon

9.6 The cron Daemon

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

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

Regularly scheduled commands can be specified according to the 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.

When the TZ environment variable is changed, either with the chtz command, a Web-based System Management application, or through SMIT, the cron daemon must be restarted. This enables the cron daemon to use the correct timezone and summer time change information for the new TZ environment variable.

The cron daemon creates a log of its activities in the /var/adm/cron/log file.

9.6.1 Crontab File Record Format

A crontab file contains entries for each cron job. Entries are separated by newline characters. Each crontab file entry contains six fields separated by spaces or tabs in the following form:

minute  hour  day_of_month  month  weekday  command

These fields accept the following values:

0 through 59
0 through 23
1 through 31
1 through 12
0 through 6 for Sunday through Saturday
a shell command

You must specify a value for each field. Except for the command field, these fields can contain the following:


Any character preceeded by a backslash (including the %) causes that character to be treated literally.

For example, if you have written a script fullbackup stored in the /root directory, and you want schedule it to run at 1 am on the 15th of every month, use the crontab -e command to add an entry as follows:

0 1 15 * * /fullbackup


The execution permission bit of the /fullbackup file must be on.

9.6.2 Housekeeping

When you have logged in as root or used the su command to become root, the crontab -l command shows that these are three commented entries in the crontab file. They are:

These are housekeeping jobs that you can enable to clean up your system. Use the crontab -e command to remove the # mark in column 1 to enable the jobs. Also, you may change the time when you want the job to run. A sample crontab file is shown in Figure 84:

Figure 84: Sample crontab File The skulker Command

The skulker command is a command file for periodically purging obsolete or unneeded files from file systems. Candidate files include files in the /tmp directory, files older than a specified age, a.out files, core files, or ed.hup files.

The skulker command is normally invoked daily, often as part of an accounting procedure run by the cron command during off-peak periods. Modify the skulker command to suit local needs following the patterns shown in the distributed version. System users should be made aware of the criteria for automatic file removal.

The find command and the xargs command form a powerful combination for use in the skulker command. Most file selection criteria can be expressed conveniently with find expressions. The resulting file list can be segmented and inserted into rm commands using the xargs command to reduce the overhead that would result if each file were deleted with a separate command.


Because the skulker command is run by a root user and its whole purpose is to remove files, it has the potential for unexpected results. Before installing a new skulker command, test any additions to its file removal criteria by running the additions manually using the xargs -p command. After you have verified that the new skulker command removes only the files you want removed, you can install it.

To enable the skulker command, you should use the crontab -e command to remove the comment statement by deleting the # (pound sign) character from the beginning of the /usr/sbin/skulker line in the /var/spool/cron/crontabs/root file. The /usr/lib/spell/compress Command

This is not the AIX compress command. The /usr/lib/spell/compress command is a shell script to compress the spell program log.

To enable the /usr/lib/spell/compress command, you should use the crontab -e command to remove the comment statement by deleting the # (pound sign) character from the beginning of the /usr/lib/spell/compress line in the /var/spool/cron/crontabs/root file.

The script is shown in Figure 85:

Figure 85: /usr/lib/spell/compress Script

This script removes all duplicated words in the /usr/lib/spell/spellhist file. This file is updated when the users invoke the spell command. The /usr/lib/smdemon.cleanu Command

The smdemon.cleanu command is a shell procedure that cleans up the sendmail command queue and maintains the /var/spool/mqueue/log file.

To enable the smdemon.cleanu command, you must remove the comment statement by deleting the # (pound sign) character from the beginning of the smdemon.cleanu line in the /var/spool/cron/crontabs/root file. If the /var/spool/mqueue directory does not exist, do not change the /var/spool/cron/crontabs/root file.

Be careful that the average size of a log file for each smdemon.cleanu session multiplied by the number of log files does not use more space than you need. You can arrange the number of log files to suit your needs.


The smdemon.cleanu command is not usually entered on the command line. The command is executed by the cron daemon.

9.7 Quiz