[deployment-guide/comm-rel: 54/727] modified Cron chapter

Jaromir Hradilek jhradile at fedoraproject.org
Tue Oct 19 12:28:39 UTC 2010


commit 012dbd25ae44053d6089d6e5bb83de8abd5715ef
Author: Martin Prpic <mprpic at redhat.com>
Date:   Sun Jul 18 12:05:19 2010 +0200

    modified Cron chapter

 en-US/Automated_Tasks.xml |   82 +++++++++++++++++++++++++++++++++------------
 1 files changed, 60 insertions(+), 22 deletions(-)
---
diff --git a/en-US/Automated_Tasks.xml b/en-US/Automated_Tasks.xml
index 4a508f8..5065074 100644
--- a/en-US/Automated_Tasks.xml
+++ b/en-US/Automated_Tasks.xml
@@ -8,7 +8,7 @@
     significance="normal">
     <primary>Automated Tasks</primary>
   </indexterm>
-  <para>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. &MAJOROS; is pre-configured to run important system tasks to keep the system updated. For example, the slocate database used by the <command>locate</command> command is updated daily. A system administrator can use automated tasks to perform periodic backups, monitor the system, run custom scripts, and more.</para>
+  <para>In Linux, tasks, which are also known as <firstterm>jobs</firstterm>, 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. &MAJOROS; is pre-configured to run important system tasks to keep the system updated. For example, the slocate database used by the <command>locate</command> command is updated daily. A system administrator can use automated tasks to perform periodic backups, monitor the system, run custom scripts, and more.</para>
   <para>&MAJOROS; comes with several automated tasks utilities: <command>cron</command>, <command>at</command>, and <command>batch</command>.</para>
   <indexterm
     significance="normal">
@@ -16,14 +16,22 @@
   </indexterm>
   <section
     id="s1-autotasks-cron">
-    <title>Cron</title>
-    <para>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.</para>
-    <para>Cron assumes that the system is on continuously. If the system is not on when a task is scheduled, it is not executed. To schedule one-time tasks, refer to <xref
+    <title>Cron and Anacron</title>
+    <para>Both, Cron and Anacron, are daemons 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.</para>
+    <para>Cron assumes that the system is on continuously. If the system is not on when a job is scheduled, it is not executed. Cron allows jobs to be run as often as every minute. Anacron does not assume the system is always on, remembers every scheduled job, and executes it the next time the system is up. However, Anacron can only run a job once a day.    
+    To schedule reccuring jobs, refer to <xref linkend="s2-autotasks-cron-configuring"/>. To schedule one-time jobs, refer to <xref
         linkend="s1-autotasks-at-batch"/>.</para>
-    <para>To use the cron service, the <filename>cronie</filename> RPM package must be installed and the <command>crond</command> service must be running. To determine if the package is installed, use the <command>rpm -q cronie</command> command. To determine if the service is running, use the command <command>/sbin/service crond status</command>.</para>
+    <para>To use the cron service, the <filename>cronie</filename> RPM package must be installed and the <command>crond</command> service must be running. Anacron is sub-package of cronie. To determine if these packages are installed, use the <command>rpm -q cronie cronie-anacron</command> command. </para>
+    <section
+      id="s2-autotasks-cron-service"
+      lang="en-US,as-IN,bn-IN,gu-IN,hi-IN,kn-IN,ml-IN,mr-IN,or-IN,pa-IN,si-LK,ta-IN,te-IN">
+      <title>Starting and Stopping the Service</title>
+      <para>To determine if the service is running, use the command <command>/sbin/service crond status</command>. To start the cron service, use the command <command>/sbin/service crond start</command>. To stop the service, use the command <command>/sbin/service crond stop</command>. It is recommended that you start the service at boot time. Refer to <xref
+          linkend="ch-Controlling_Access_to_Services"/> for details on starting the cron service automatically at boot time.</para>
+    </section>
     <section
       id="s2-autotasks-cron-configuring">
-      <title>Configuring Cron Tasks</title>
+      <title>Configuring Tasks</title>
       <indexterm
         significance="normal">
         <primary>cron</primary>
@@ -35,18 +43,55 @@
           <filename>crontab</filename>
         </primary>
       </indexterm>
-      <para>The main configuration file for cron, <filename>/etc/crontab</filename>, contains the following lines:</para>
+      <para>The main configuration file to schedule jobs is <filename>/etc/anacrontab</filename>, which contains the following lines:</para>
       <screen>
-SHELL=/bin/bash
+SHELL=/bin/sh
 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
+MAILTO=root
+# the maximal random delay added to the base delay of the jobs
+RANDOM_DELAY=45
+# the jobs will be started during the following hours only
+START_HOURS_RANGE=3-22
+
+#period in days   delay in minutes   job-identifier   command
+1         5     cron.daily    nice run-parts /etc/cron.daily
+7         25    cron.weekly   nice run-parts /etc/cron.weekly
+ at monthly  45    cron.monthly  nice run-parts /etc/cron.monthly
+</screen>
+<para>
+  The first three lines are variables used to configure the environment in which the anacron tasks are run. The <computeroutput>SHELL</computeroutput> variable tells the system which shell environment to use (in this example the bash shell). The <computeroutput>PATH</computeroutput> variable defines the path used to execute commands. The output of the anacron jobs are emailed to the username defined with the <computeroutput>MAILTO</computeroutput> variable. If the <computeroutput>MAILTO</computeroutput> variable is defined as an empty string (<computeroutput>MAILTO=""</computeroutput>), email is not sent. 
+</para>
+<para>
+  The next two lines are variables that modify the time for each scheduled job. The <computeroutput>RANDOM_DELAY</computeroutput> variable denotes the maximum number of minutes that can randomly be added to the delay variable specified for each job. The minimum delay value is set, by default, to 6 minutes. A <computeroutput>RANDOM_DELAY</computeroutput> set to 12 would therefore add, randomly, between 6 and 12 minutes to the delay. <computeroutput>RANDOM_DELAY</computeroutput> can also be set to a value below 6, or even 0. When set to 0, no random delay is added. This proves to be useful when, for example, more computers that share one network connection need to download the same data every day. The <computeroutput>START_HOURS_RANGE</computeroutput> variable defines an interval (in hours) when scheduled jobs can be run. In case this time interval is missed, for example, due to a power down, then scheduled jobs are not executed that day.
+</para>
+<para>The rest of the lines in the <filename>/etc/anacrontab</filename> file represent scheduled jobs and have the following format:
+<screen>
+period in days   delay in minutes   job-identifier   command
 </screen>
-<!-- silas: mention how to stagger/randomize automated task execution. For example, disk latency in storage systems can suffer at precisely 4:02AM each day, causing problems in guests and even panicks. Root cause could be the 4:02 default crontab entry that does "run-parts /etc/cron.daily". According to Marcela, randomly delayed jobs will be fully supported by cronie with cronie-anacron. -->
+<itemizedlist>
+  <listitem>
+    <para>
+      <computeroutput>period in days</computeroutput> - specifies the frequency of execution of the job in days. This variable can be represented by an integer or a macro (<computeroutput>@daily</computeroutput>, <computeroutput>@weekly</computeroutput>, <computeroutput>@monthly</computeroutput>), where <computeroutput>@daily</computeroutput> denotes the same value as the integer 1, <computeroutput>@weekly</computeroutput> the same as 7, and <computeroutput>@monthly</computeroutput> specifies that the job is run once a month, independent on the length of the month.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+      <computeroutput>delay in minutes</computeroutput> - specifies the number of minutes anacron waits, if necessary, before executing a job. This variable is represented by an integer where 0 means no delay.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+      <computeroutput>job-identifier</computeroutput> - specifies a unique name of a job which is used in the log files.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+      <computeroutput>command</computeroutput> - specifies the command to execute. The command can either be a command such as <computeroutput>ls /proc >> /tmp/proc</computeroutput> or a command to execute a custom script.
+    </para>
+  </listitem>
+</itemizedlist>
+</para>
+
       <para>The first four lines are variables used to configure the environment in which the cron tasks are run. The <computeroutput>SHELL</computeroutput> variable tells the system which shell environment to use (in this example the bash shell), while the <computeroutput>PATH</computeroutput> variable defines the path used to execute commands. The output of the cron tasks are emailed to the username defined with the <computeroutput>MAILTO</computeroutput> variable. If the <computeroutput>MAILTO</computeroutput> variable is defined as an empty string (<computeroutput>MAILTO=""</computeroutput>), email is not sent. The <computeroutput>HOME</computeroutput> variable can be used to set the home directory to use when executing commands or scripts.</para>
       <para>Each line in the <filename>/etc/crontab</filename> file represents a task and has the following format:</para>
       <screen>
@@ -125,13 +170,6 @@ minute   hour   day   month   dayofweek   command
       <para>If the file <filename>cron.allow</filename> exists, only users listed in it are allowed to use cron, and the <filename>cron.deny</filename> file is ignored.</para>
       <para>If <filename>cron.allow</filename> does not exist, users listed in <filename>cron.deny</filename> are not allowed to use cron.</para>
     </section>
-    <section
-      id="s2-autotasks-cron-service"
-      lang="en-US,as-IN,bn-IN,gu-IN,hi-IN,kn-IN,ml-IN,mr-IN,or-IN,pa-IN,si-LK,ta-IN,te-IN">
-      <title>Starting and Stopping the Service</title>
-      <para>To start the cron service, use the command <command>/sbin/service crond start</command>. To stop the service, use the command <command>/sbin/service crond stop</command>. It is recommended that you start the service at boot time. Refer to <xref
-          linkend="ch-Controlling_Access_to_Services"/> for details on starting the cron service automatically at boot time.</para>
-    </section>
   </section>
   <section
     id="s1-autotasks-at-batch">


More information about the docs-commits mailing list