Installation guide
200 Chapter 22. Automated Tasks
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/anacrontab as with the cron configuration file.
The default configuration file looks similar to the following:
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# These entries are useful for a Red Hat Linux system.
1 5 cron.daily run-parts /etc/cron.daily
7 10 cron.weekly run-parts /etc/cron.weekly
30 15 cron.monthly run-parts /etc/cron.monthly
Figure 22-1. Default anacrontab
As you can see in Figure 22-1, anacron for Red Hat Linux is configured to make sure the
daily, weekly, and monthly cron tasks are run.
22.2.2. Starting and Stopping the Service
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.
22.3. At and Batch
While cron and anacron are used to schedule recurring tasks, the at command is used to
schedule a one-time task at a specific time. The batch command is used to schedule a one-
time task to be executed when the systems load average drops below 0.8.
To use at or batch you must have the at RPM package installed, and the atd service must be
running. To determine if the package is installed, use the rpm -q at command. To determine
if the service is running, use the command /sbin/service atd status.
22.3.1. Configuring At Jobs
To schedule a one-time job at a specific time, type the command at time, where time is the
time to execute the command.
The argument time can be one of the following:
• HH:MM format — For example, 04:00 specifies 4:00AM. If the time is already pasted, it is
executed at the specified time the next day.
• midnight — Specifies 12:00AM.
• noon — Specifies 12:00PM.