Chapter 34.317Automated TasksIn Linux, tasks can be configured to run automatically within a specified period of time, on a specifieddate, or when the system load average is below a specified number. Red Hat Enterprise Linux ispre-configured to run important system tasks to keep the system updated. For example, the slocatedatabase used by the locate command is updated daily. A system administrator can use automatedtasks to perform periodic backups, monitor the system, run custom scripts, and more.Red Hat Enterprise Linux comes with several automated tasks utilities: cron, at, and batch.34.1. CronCron is a daemon that can be used to schedule the execution of recurring tasks according to acombination 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, itis not executed. To schedule one-time tasks, refer to Section 34.2, “At and Batch”.To use the cron service, the vixie-cron RPM package must be installed and the crond servicemust 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.34.1.1. Configuring Cron TasksThe main configuration file for cron, /etc/crontab, contains the following lines:SHELL=/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binMAILTO=rootHOME=/# run-parts01 * * * * root run-parts /etc/cron.hourly02 4 * * * root run-parts /etc/cron.daily22 4 * * 0 root run-parts /etc/cron.weekly42 4 1 * * root run-parts /etc/cron.monthlyThe first four lines are variables used to configure the environment in which the cron tasks are run.The SHELL variable tells the system which shell environment to use (in this example the bash shell),while the PATH variable defines the path used to execute commands. The output of the cron tasks areemailed to the username defined with the MAILTO variable. If the MAILTO variable is defined as anempty string (MAILTO=""), email is not sent. The HOME variable can be used to set the home directoryto use when executing commands or scripts.Each line in the /etc/crontab file represents a task and has the following format:minute hour day month dayofweek command• minute — any integer from 0 to 59• hour — any integer from 0 to 23