Is it true that “cron.daily runs anacron everyhour”?

On Ubuntu, what is the calling relation between cron and anacron?
I am confused by looking at /etc/anacrontab, /etc/cron.daily/0anacron and /etc/crontab.

From https://askubuntu.com/a/848638/1471

cron.daily runs anacron everyhour.

What does “cron.daily runs anacron everyhour” mean?

Is it “cron runs anacron daily via cron.daily” instead? Thanks.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You are quoting the text wrong. It says cron.daily runs anacron every day (the text may have been updated since). Also that is exactly what it means.

anacron is not (regardless of what the AskUbuntu answer says) a daemon. It’s a small program that needs to be invoked by cron on a daily basis (or more often, though it won’t make any difference) to run jobs specified in /etc/anacrontab.

Method 2

The anacron manpage describes what it’s supposed to do, and to some extent how it does it. You should trust that, and the contents of the files on your system, more than information you find on unrelated sites on the Internet (including this answer of course).

anacron’s job is to ensure that daily, weekly and monthly jobs are run periodically, even if the system isn’t running at the appropriate times. It doesn’t need cron to operate but it does need to avoid duplicating cron’s work.

/etc/anacrontab tells anacron what to run; by default, that’s all the cron jobs defined in files under /etc/cron.{daily,weekly,monthly}, at the appropriate intervals. When anacron is run (in a mode where it is asked to actually run the jobs it manages), it checks to see when the jobs were last run, and only runs them if a period of time consistent with the jobs’ intended periodicity has elapsed.

/etc/cron.{daily,weekly,monthly}/0anacron take care of ensuring that anacron is aware of cron’s operation: every time cron processes its daily, weekly, and monthly jobs, the first job it runs updates anacron’s timestamps, resetting the counter for the elapsed time since the last execution of the corresponding set of jobs.

/etc/cron.d/anacron and /lib/systemd/system/anacron.timer ensure that, on systems with either cron or systemd installed, anacron is run periodically: daily with cron, hourly with systemd. anacron is also run at system boot (via its init script) and when the power status changes (on resume, or when AC power is connected).


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x