Installation guide

Chapter 22.
Automated Tasks
In Linux, tasks can be configured to run automatically within a specified period of time,
on a specified date, or when the system load average is below a specified number. Red Hat
Linux comes preconfigured to run important system tasks to keep the system updated. For
example, the slocate database used by the locate command is updated daily. A system
administrator can use automated tasks to perform periodic backups, monitor the system,
run custom scripts, and more.
Red Hat Linux comes with four automated tasks utilities: cron, anacron, at, and batch.
22.1. Cron
Cron is a daemon that can be used to schedule the execution of recurring tasks according to
a combination of the time, day of the month, month, day of the week, and week.
Cron assumes that the system is on continuously. If the system is not on when a task is
scheduled, it is not executed. To configure tasks based on time periods instead of exact times,
refer to Section 22.2. To schedule one-time tasks, refer to Section 22.3.
To use the cron service, you must have the vixie-cron RPM package installed, and the
crond service must be running. To determine if the package is installed, use the rpm
-q vixie-cron command. To determine if the service is running, use the command
/sbin/service crond status.
22.1.1. Configuring Cron Tasks
The main configuration file for cron, /etc/crontab, contains the following lines:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
The first four lines are variables used to configure the environment in which the cron tasks
are run. The value of the SHELL variable tells the system which shell environment to use (in
this example the bash shell), and the PATH variable defines the path used to execute com-
mands. The output of the cron tasks are emailed to the username defined with the MAILTO
variable. If the MAILTO variable is defined as an empty string (MAILTO=""), email will not
be sent. The HOME variable can be used to set the home directory to use when executing
commands or scripts.
Each line in the /etc/crontab file represents a task and has the format:
minute hour day month dayofweek command