With Debian 9 (stretch) and Debian 10 (buster), the schedule of unattended-upgrades is determined in two steps:
- The system scheduler (e.g. systemd timers or cron/anacron), and
- APT::Periodic intervals.
A lower frequency in one of these will obstruct the higher frequency in the other, so be sure that settings are correct for both steps.
1. The system scheduler
The process is started by the following two systemd timers:
apt-daily.timer
to update the package lists (apt-get update
), and
apt-daily-upgrade.timer
to install the upgrades (unattended-upgrade
).
(The anacron job /etc/cron.daily/apt-compat
still exists, but exits if it detects systemd. See other answers or anacron documentation on changing the schedule if you don't use systemd.)
To modify your update schedule:
$ sudo systemctl edit apt-daily.timer
This creates /etc/systemd/system/apt-daily.timer.d/override.conf
. Fill it as follows, for example:
[Timer]
OnCalendar=
OnCalendar=01:00
RandomizedDelaySec=15m
Same for the upgrade schedule:
$ sudo systemctl edit apt-daily-upgrade.timer
[Timer]
OnCalendar=
OnCalendar=01:30
RandomizedDelaySec=0
To check your work:
$ systemctl cat apt-daily{,-upgrade}.timer
$ systemctl --all list-timers apt-daily{,-upgrade}.timer
(Taken partly from Debian Wiki: UnattendedUpgrades.)
2. APT::Periodic intervals
No matter if you use the systemd timers or the anacron job as the system scheduler, both call the same script in the end. That script makes a new, second decision of whether it is time to run again, but now based on the intervals set in APT::Periodic. You should normally find those settings in /etc/apt/apt.conf.d/20auto-upgrades
:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
I always thought the "1"
value here simply meant True or On, but actually, it is the minimal interval between runs, expressed in days. If the script determines that less time has passed since the last time the requested action was performed, it will simply not perform the action, regardless of the fact that the system scheduler called for it.
With apt versions above 1.5 (Debian 10 buster) you can change the APT::Periodic values from "1"
to "always"
. You do this once and from then on, you only need to interact with the system scheduler (systemd timer or anacron) to change the schedule.
For more details on the above, or if you want to schedule unattended-upgrades to run more than once per day, see my answer here: How to run unattended-upgrades not daily but every few hours.