Anacron is a task scheduler similar to cron except that it does not
require the system to run continuously. It can be used to run the
daily, weekly, and monthly jobs usually run by cron.
Anacron tasks are listed in the configuration file
/etc/anacron.
Each line in the configuration file corresponds to a task and has the
format:
period delay job-identifier command |
period — frequency (in
days) to execute the command
delay — delay time in minutes
job-identifier —
description of the task, used in Anacron messages and as the name
of the job's timestamp file, can contain any non-blank characters
(except slashes).
command — command to execute
For each tasks, Anacron determines if the task has been executed
within the period specified in the period
field of the configuration file. If it has not been executed within
the given period, Anacron executes the command specified in the
command field after waiting the
number of minutes specified in the
delay field.
After the task is completed, Anacron records the date in a timestamp
file in the /var/spool/anacron directory. Only
the date is used (not the time), and the value of the
job-identifier is used as the
filename for the timestamp file.
Environment variables such as SHELL
and PATH can be defined at the top of
/etc/anacron as with the cron configuration file.
The default configuration file looks similar to the following:
As you can see in Figure 22-1, the anacrontab
for Red Hat Linux is configured to make sure the daily, weekly, and monthly
cron tasks are run.
To start the anacron service, use the command /sbin/service
anacron start. To stop the service, use the command
/sbin/service anacron stop. It is recommended that
you start the service at boot time. Refer to Chapter 8 for details on starting the anacron service
automatically at boot time.