I see where to set the frequency ie weekly, daily, etc, but not how to set what time of day it checks.
3 Answers
Ubuntu 18.04 and earlier releases only:
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.

- 62,253

- 293,335
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.

- 11
On Ubuntu systems 20.04 and newer, the daily apt update is handled by a systemd timer (not a cronjob anymore).
$ systemctl list-timers | grep apt-daily.timer
Tue 2023-03-21 14:53:37 CDT 1h 38min left Mon 2023-03-20 14:24:10 CDT 22h ago apt-daily.timer apt-daily.service
Let's parse this out:
Tue 2023-03-21 14:53:37 CDT 1h 38min left -- when it will run next
Mon 2023-03-20 14:24:10 CDT 22h ago -- when it last ran
apt-daily.timer -- the timer name
apt-daily.service -- the service triggered by the timer
Hmmm. Those jobs are not exactly 24 hours apart. Let's look at the actual timer file to find out why. It's located at /lib/systemd/system/apt-daily.timer
:
[Unit]
Description=Daily apt download activities
[Timer]
OnCalendar=--* 6,18:00
RandomizedDelaySec=12h
Persistent=true
[Install]
WantedBy=timers.target
There's some BIG NEWS in this file!
OnCalendar=*-*-* 6,18:00 -- It runs TWICE each day
RandomizedDelaySec=12h -- It never runs at the same time. Random delay of up to 12 hours.
So now we know why updates seem to be random, and we know the settings to change if we want apt-update to run at a specific time, or more/less often.
Here's how to customize your daily apt update time and frequency:
DO NOT edit
/lib/systemd/system/apt-daily.timer
. That file will be overwritten every time the package is updated.Instead, use an override file in /etc and make the changes in the override file. To restore the default behavior, simply delete the override file in /etc
Create the override file:
sudo cp /lib/systemd/system/apt-daily.timer /etc/systemd/system/apt-daily.timer
Make your changes to the override file. For example, to reduce the frequency to once daily, preferably in the mornings:
OnCalendar=*-*-* 6:00 RandomizedDelaySec=6h
Note: Be a good neighbor. Do not hammer servers that do not belong to you.
Changing the defaults may have consequences: You may receive security patches less often.
Test your changes. After a changed apt-daily timer has had a scheduled run, test that it ran successfully. The service, when run, updates the timestamps in this file:
$ ls -l /var/lib/apt/periodic/update-success-stamp -rw-r--r-- 1 root root 0 Mar 21 10:46 update-success-stamp

- 62,253
APT::Periodic::RandomSleep
APT configuration setting; a maximum of0
means it will always happen immediately (but remember why the random sleep is there!). – JanC Apr 21 '11 at 15:26