I am trying to understand how anacron works (in Fedora). I have three related questions. I am confused because of the following statement from the anacrontab manual:
The START_HOURS_RANGE 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.
The first, main question is: What does the phrase "time interval is missed" mean?
I am aware that there are software clock and hardware clock, and that the software clock depends on the hardware clock. As I understand, if the power is down long enough, then after booting the system, the hardware clock has to be adjusted from the software clock, therefore the software clock has to be adjusted independently (manually or automatically).
So, here comes the second question: Does it mean that if anacron should have been run in the time that the system was down, and after booting – in the time anacron was running – it was still not having proper time, then anacron was thinking that it is not yet the time to run (and therefore it will not run)?
I realise that anacron is not a daemon itself, as stated in this stackexchange answer. As the Fedora documentation on anacron states, the anacron jobs are run by the crond
daemon. Also, is states that the anacron jobs will be run as soon as the system is up.
So, here comes the third question: If the answer for the second question is "yes", then could the system time be adjusted before crond
run anacron, and therefore anacron will run however (because at that time the time will be correct)?
UPDATE
Maybe let us have an example: let us suppose that I have scheduled anacron on Fedora to run some jobs daily – and the system normally is running all the time. I left the default configuration that Fedora provides, that is, anacron will run only within the time range 3:05 and 22:50 (I hope that I understand it correctly what the manual says) – if, of course, the system will be running in this time range. Now, let us suppose that there was a power down from 2:30 to 4:30, so Fedora started to boot at 4:30. Let us suppose that crond run anacron two minutes later (4:32), just as usual, and let us suppose that in that time the system clock was still not set correctly. Anacron sees that the system clock is set to 2:32, so it thinks "it is yet not the time to run my jobs, because I am scheduled to run them at 3:05 earliest".
From this I understand that it is not run that day (and the next time it will be run is the next day starting from 3:05).
And now the other case: let us suppose that the system time was adjusted at 2:31, one minute before crond will run anacron. When it runs anacron at 4:32 (now, the correct time), anacron sees the time and it thinks "OK, so I have to run my jobs. Let us wait the random delay that is defined in my configuration and run the jobs". It waits random delay between 4:32 4:37 and 5:17 5:22 and after that it runs its jobs.
Am I right?
anacron
does not have a concept of "incorrect time" and always assumes it is correct. Therefore it will always run tasks that were missed when it was not active, when configured to do so. – Mio Rin Oct 16 '18 at 15:12