'what does anacron anacrontab delay in minutes and RANDOM_DELAY actually do?

The manual says:

       The delay in minutes variable 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.
       The  RANDOM_DELAY  variable  denotes the maximum number of minutes that will be
       added to the delay in minutes variable which is specified for each job.  A RAN‐
       DOM_DELAY  set to 12 would therefore add, randomly, between 0 and 12 minutes to
       the delay in minutes for each job in that particular anacrontab.  When  set  to
       0, no random delay is added.

What does "if necessary" mean? Does this mean, if my /etc/anacrontab entry is:

1       5       cron.daily              nice run-parts /etc/cron.daily

that cron.daily is run five minutes after 3 am (if the system is up at 3) always, or does it mean it runs 5 minutes after every hour only if some conditions are met? If

RANDOM_DELAY=45

does this always delay the execution of cron.daily by 0-45 minutes (inclusive)? If so, is that on top of the 5 minutes? Or do some conditions need to be met before RANDOM_DELAY is applied as with the 5 minutes delay?



Solution 1:[1]

/var/lib/logrotate/logrotate.status shows when logrotate was actually run. This demonstrates the RANDOM_DELAY is always in effect. The "delay in minutes" delays the onset of that random delay. This field is required because in /etc/anacrontab START_HOURS_RANGE=3-22 is defined. This only specifies the hour to start at, 3 am if the system is up. The "delay in minutes" field being set to 5 starts the job at 3:05, not 3. However the random delay of 0-45 minutes (inclusive, I believe) is added to 3:05, so the actual start range is 3:05-3:50 (if the system is up at that time). If the system is temporarily down at that time, the job can start anywhere in the range 3:05 - 22:50 depending on when the system goes back online.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cavalcade