|
| 1 | + |
| 2 | + What is Anacron ? |
| 3 | + ----------------- |
| 4 | + |
| 5 | + Anacron is a periodic command scheduler. It executes commands at |
| 6 | +intervals specified in days. Unlike cron, it does not assume that the |
| 7 | +system is running continuously. It can therefore be used to control |
| 8 | +the execution of daily, weekly and monthly jobs (or anything with a |
| 9 | +period of n days), on systems that don't run 24 hours a day. When |
| 10 | +installed and configured properly, Anacron will make sure that the |
| 11 | +commands are run at the specified intervals as closely as |
| 12 | +machine-uptime permits. |
| 13 | + |
| 14 | + Every time Anacron is run, it reads a configuration file that |
| 15 | +specifies the jobs Anacron controls, and their periods in days. If a |
| 16 | +job wasn't executed in the last n days, where n is the period of that |
| 17 | +job, Anacron executes it. Anacron then records the date in a special |
| 18 | +timestamp file that it keeps for each job, so it can know when to run |
| 19 | +it again. When all the executed commands terminate, Anacron exits. |
| 20 | + |
| 21 | + It is recommended to run Anacron from the system boot-scripts. |
| 22 | +This way the jobs "whose time has come" will be run shortly after the |
| 23 | +machine boots. A delay can be specified for each job so that the |
| 24 | +machine isn't overloaded at boot time. |
| 25 | + |
| 26 | + In addition to running Anacron from the boot-scripts, it is also |
| 27 | +recommended to schedule it as a daily cron-job (usually at an early |
| 28 | +morning hour), so that if the machine is kept running for a night, |
| 29 | +jobs for the next day will still be executed. |
| 30 | + |
| 31 | + |
| 32 | + Why this may be useful ? |
| 33 | + ------------------------ |
| 34 | + |
| 35 | + Most Unix-like systems have daily, weekly and monthly scripts that |
| 36 | +take care of various "housekeeping chores" such as log-rotation, |
| 37 | +updating the "locate" and "man" databases, etc. Daily scripts are |
| 38 | +usually scheduled as cron-jobs to execute around 1-7 AM. Weekly |
| 39 | +scripts are scheduled to run on Sundays. On machines that are turned |
| 40 | +off for the night or for the weekend, these scripts rarely get run. |
| 41 | + |
| 42 | + Anacron solves this problem. These jobs can simply be scheduled as |
| 43 | +Anacron-jobs with periods of 1, 7 and 30 days. |
| 44 | + |
| 45 | + |
| 46 | + What Anacron is not ? |
| 47 | + --------------------- |
| 48 | + |
| 49 | + Anacron is not an attempt to make cron redundant. It cannot |
| 50 | +currently be used to schedule commands at intervals smaller than days. |
| 51 | +It also does not guarantee that the commands will be executed at any |
| 52 | +specific day or hour. |
| 53 | + |
| 54 | + It isn't a full-time daemon. It has to be executed from boot |
| 55 | +scripts, from cron-jobs, or explicitly. |
| 56 | + |
| 57 | + |
| 58 | + For more details, see the anacron(8) manpage. |
| 59 | + |
| 60 | + |
| 61 | + Requirements |
| 62 | + ------------ |
| 63 | + |
| 64 | + - A Linux system. (maybe other *NIX systems) |
| 65 | + - A functioning syslog daemon. |
| 66 | + - A functioning /usr/lib/sendmail command. (all MTAs should have |
| 67 | + that). |
| 68 | + |
| 69 | + |
| 70 | + Compilation and Installation |
| 71 | + ---------------------------- |
| 72 | + |
| 73 | + - Untar the source package. |
| 74 | + |
| 75 | + - Check the Makefile. Edit as required. |
| 76 | + |
| 77 | + - Check the top of "global.h". You may want to change the syslog |
| 78 | + facility and priorities, and the path to your MTA's sendmail |
| 79 | + compatible command (/usr/lib/sendmail). |
| 80 | + |
| 81 | + - cd to the directory. |
| 82 | + |
| 83 | + - Type "make". |
| 84 | + You can safely ignore warnings of the form: "*.d: No such file or |
| 85 | + directory" |
| 86 | + |
| 87 | + - Become root. Type "make install". |
| 88 | + |
| 89 | + |
| 90 | + Setup |
| 91 | + ----- |
| 92 | + |
| 93 | +1. Locate your system's daily, weekly and monthly cron-jobs. |
| 94 | + See your cron documentation for more details. |
| 95 | + |
| 96 | +2. Decide which of these jobs should be controlled by Anacron. |
| 97 | + Remember that Anacron does not guarantee execution at any specific |
| 98 | + day of the month, day of the week, or time of day. Jobs for which |
| 99 | + the timing is critical should probably not be controlled by |
| 100 | + Anacron. |
| 101 | + |
| 102 | +3. Comment these jobs out of their crontab files. (You may have to |
| 103 | + use the "crontab" command for this. See the cron documentation.) |
| 104 | + |
| 105 | +4. Put them in /etc/anacrontab. Note that the format is not the same |
| 106 | + as the crontab entries. See the anacrontab(5) manpage. Here's an |
| 107 | + example from a typical Debian system: |
| 108 | + |
| 109 | +-----Cut |
| 110 | +# /etc/anacrontab example |
| 111 | +SHELL=/bin/sh |
| 112 | +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
| 113 | +# format: period delay job-identifier command |
| 114 | +1 5 cron.daily run-parts /etc/cron.daily |
| 115 | +7 10 cron.weekly run-parts /etc/cron.weekly |
| 116 | +30 15 cron.monthly run-parts /etc/cron.monthly |
| 117 | +-----Cut |
| 118 | + |
| 119 | +5. Put the command "anacron -s" somewhere in your boot-scripts. |
| 120 | + Make sure that syslogd is started before this command. |
| 121 | + |
| 122 | +6. Schedule the command "anacron -s" as a daily cron-job (preferably |
| 123 | + at some early morning hour). This will make sure that jobs are run |
| 124 | + when the systems is left running for a night. |
| 125 | + |
| 126 | +That's it. |
| 127 | + |
| 128 | +It is a good idea to check what your daily, weekly and monthly scripts |
| 129 | +actually do, and disable any parts that may be irrelevant for your |
| 130 | +system. |
| 131 | + |
| 132 | + |
| 133 | + Credits |
| 134 | + ------- |
| 135 | + |
| 136 | +Anacron was originally conceived and implemented by Christian Schwarz |
| 137 | +<schwarz@monet.m.isar.de>. |
| 138 | + |
| 139 | +The current implementation is a complete rewrite by Itai Tzur |
| 140 | +<itzur@actcom.co.il>. |
| 141 | + |
| 142 | +Current code base maintained by Sean 'Shaleh' Perry <shaleh@(debian.org|valinux.com)>. |
0 commit comments