15

I was reading about the differences between cron and anacron and I realized that anacron, unlike cron is not a daemon. So I'm wondering how does it work actually if it's not a daemon.

0

2 Answers 2

21

It uses a variety of methods to run:

  • if the system is running systemd, it uses a systemd timer (in the Debian package, you’ll see it in /lib/systemd/system/anacron.timer);
  • if the system isn’t running systemd, it uses a system cron job (in /etc/cron.d/anacron);
  • in all cases it runs daily, weekly and monthly cron jobs (in /etc/cron.{daily,weekly,monthly}/0anacron);
  • it also runs at boot (from /etc/init.d/anacron or its systemd unit).
2
  • I've seen the {a,b,c} notation around; can I use that in my shell? (I don't have access to it right now or I'd test.) Does it mean what it seems to -- that is, all files with the {...} replaced with any of the comma-separated things?
    – anon
    Dec 15, 2017 at 22:11
  • 3
    @QPaysTaxes - Bash (and a few other shells) expands braces in that way - see Bash Reference Manual: Brace Expansion
    – shalomb
    Dec 15, 2017 at 22:14
6

anacron is not a daemon, and therefore it needs to be run periodically by other means. Most often, this means executing it with a cron job once a day, and possibly on bootup as well.

This may look like the following in root's crontab, for example:

@reboot /usr/local/sbin/anacron -ds
@daily  /usr/local/sbin/anacron -ds

Linux systems that uses systemd may do this differently, obviously, but still need to facilitate at least one run of anacron per 24 hour period.

Running anacron more than once every 24 hours is pointless as the shortest period one can schedule jobs through anacron is once a day.

1
  • Thanks. (1) I was wondering what "not a daemon" means? (2) regarding your last sentence: "The systemd timer runs anacron hourly to reduce the delay between resuming a suspended system and the next anacron run" unix.stackexchange.com/questions/478803/…
    – Tim
    Nov 1, 2018 at 11:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .