I haven't changed my /etc/crontab, yet. It's still the default content, which is also the default content for many Linux distros:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.


# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

Why is the cron.hourly line the only one without test -x /usr/sbin/anacron? Why isn't there a cron.hourly in anacrontab, too?


As @JakeGould commented, the answer to "What exactly does test -x /usr/sbin/anacron do?" can be found at https://unix.stackexchange.com/questions/26088/etc-crontab-what-does-test-x-stand-for for example. But the main question still stands: why does the procedure for cron.hourly differ from the other lines?

  • -x checks for executable. – user534635 Jun 17 '18 at 20:24
  • 1
    Some more details here. But as to why cron.hourly doesn’t need that is a decent question. – JakeGould Jun 17 '18 at 20:26

Because the smallest period that Anacron is designed to work over is daily, so it can't be used to manage hourly cron jobs.

Anacron is designed to handle a very specific use case, namely making sure that infrequently run cron jobs still get run on systems that aren't always powered on. Realistically, there's almost nothing that both needs to be run hourly, and needs to be run immediately if an hourly run was missed. Given this, the developers of Anacron decided to allow for significantly simpler (and also more reliable) code that doesn't pay attention to the time previous tasks ran, just the date they ran. In turn, this means that Anacron is designed to operate in terms of days, not hours or minutes like most cron implementations do, and therefore it can't be used for handling hourly jobs.

In reality, Anacron doesn't actually do any scheduling itself either, which is why those entries in your /etc/crontab are there, without those, anacron won't run (or might only run on startup), so they're there to make sure it runs even if the system is on for a long time.

As far as hourly jobs in general, you will likely find /etc/cron.hourly to be empty on your system. Most of the classical uses for that (or even more frequent cron jobs) were cases where you were making sure something was up-to-date, or checking the state of some piece of hardware or software via polling. Both use cases are better served by using event-driven models instead of polling models, and thus have generally been migrated to such designs.

  • Nice. Great answer! – JakeGould Jun 18 '18 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.