Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

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.

share|improve this answer
3  
This will not set the exact time that the update happens, as there is a random sleep before the actual check for new packages happens. This is done to prevent that millions of users hit the mirrors at the same time. The default sleep is randomly chosen between 0 and 30 minutes after the start of the cron job. You can change the maximum sleep time with the APT::Periodic::RandomSleep APT configuration setting; a maximum of 0 means it will always happen immediately (but remember why the random sleep is there!). –  JanC Apr 21 '11 at 15:26
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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