Is there a way to change what time the update manager checks for updates?

I see where to set the frequency ie weekly, daily, etc, but not how to set what time of day it checks.


Solution 1:

Apt updates are triggered by a script called /etc/cron.daily/apt. /etc/cron.daily contains several scripts that happen every day, but all at the same time. In order to change the time when Update Manager updates, you need to change the time when all the /etc/cron.daily scripts fire off.

To do that you need to edit your /etc/crontab file:

sudoedit /etc/crontab # or: gksu gedit /etc/crontab

This is a fairly standard cron file that should look a little something like this:

# /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.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# 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 )
#

From this we can see cron.daily triggers at 6:25am. If you wanted to start it at 4am, you'd replace the second times line with:

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

If you need more help with the format, Wikipedia has an unusually technical page on Cron.

Solution 2:

Thanks people. Amber asked this on my behalf from a question I asked in our loco team IRC channel. I figured it was a cron job and had been digging through them (/etc/cron.*) trying to figure this out on my own. So now I won't see cpu usage spike right as I'm watching some morning news video.

There does seem to be an hour time shift. I suspect it is due to Daylight Savings Time. Here's a snip from this morning.

Apr 21 07:30:01 flounder CRON[21032]: (root) CMD (start -q anacron || :)
Apr 21 07:30:01 flounder anacron[21035]: Anacron 2.3 started on 2011-04-21
Apr 21 07:30:01 flounder anacron[21035]: Will run job `cron.daily' in 5 min.
Apr 21 07:30:01 flounder anacron[21035]: Will run job `cron.weekly' in 10 min.
Apr 21 07:30:01 flounder anacron[21035]: Jobs will be executed sequentially
Apr 21 07:35:01 flounder anacron[21035]: Job `cron.daily' started

Mark this solved.