TIme of execution of daily anacron job

I found how to do this and summarized it in my blogpost:

  • http://opensourceresearchtips.blogspot.com/2012/01/linux-anacron-tips.html

If you want to change the behaviour of anacron to execute as soon as the day changes (and not wait till 7:30 as is the default behaviour) do the following:

gksu gedit /etc/cron.d/anacron

and add the last 2 lines (the last line will restart anacron every hour):

01 0    * * *   root test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null
01 0    * * *   root start -q anacron || :
@hourly root start -q anacron || :

The answer by Khaled is not correct. Changing this line will not have an effect if anacron is installed (which it is, by default):

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

If anacron exists, test -x /usr/sbin/anacron will return true, and prevent the second half of that line from running. The other answer (editing /etc/cron.d/anacron) is correct, since that's the config that will kick off anacron itself.


as per other answers:

edit the first two columns of /etc/cron.d/anacron to change the time anachron runs.

(/etc/crontab values don't take effect due to the || ...)