40

If I place a shell script in /etc/cron.daily/, at what time of the day will it be executed?

4 Answers 4

46

Approximately 7:35am, but the exact timing will depend on anacron.

By default cron delegates the running of /etc/cron.daily jobs to anacron. /etc/crontab contains the line:

25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

but this defines the behaviour if anacron is not installed

With anacron installed, the running of cron.daily jobs is controlled by the entry in /etc/anacrontab:

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

which says run these jobs once per day, with a delay of 5 minutes.

anacron itself is run by cron, as specified in the file /etc/cron.d/anacron, which runs anacron at 7:30am.

0
41

Looking at /etc/crontab it should run at 06:25.

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 )
2
  • 7
    This is most probably wrong because anacron is installed by default. The other answer is the correct one. May 22, 2014 at 7:53
  • 3
    Yes, this aswer is generally misleading. If anacron is installed see @DaithiF's answer. Oct 17, 2015 at 13:40
10

As indicated by other answers, the result depends on whether anacron is installed. On a desktop, it is installed by default, BUT crucially it is not installed in the server distribution. So the answer is around 06:25 on a server and about 07:35 on a desktop.

1

To elaborate on the other answers, on newer systems anacron is managed by systemd. On my Ubuntu 19.10 system anacron runs from 7:30 - 23:30 every hour, with a randomized delay of 5 minutes. Anacron then runs cron.daily scripts with a 5 minute delay as defined in /etc/anacrontab.

In addition to that systemd only starts anacron when the system is connected to AC power. Have a look at /lib/systemd/system/anacron.service and /lib/systemd/system/anacron.timer for more info.

You must log in to answer this question.

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