I assume you have unattended upgrades already working? Otherwise, see here to get started with that.
Notably, in /etc/apt/apt.conf.d/20auto-upgrades
I have
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::Unattended-Upgrade "1";
There might be other lines, keep them in there.
In /etc/apt/apt.conf.d/50unattended-upgrades
I think by default the "${distro_id}:${distro_codename}-updates";
is commented, and I have it uncommented, to make:
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}";
"${distro_id}:${distro_codename}-security";
// Extended Security Maintenance; doesn't necessarily exist for
// every release and this system may not have it installed, but if
// available, the policy for updates is such that unattended-upgrades
// should also install from here by default.
"${distro_id}ESMApps:${distro_codename}-apps-security";
"${distro_id}ESM:${distro_codename}-infra-security";
"${distro_id}:${distro_codename}-updates";
// "${distro_id}:${distro_codename}-proposed";
// "${distro_id}:${distro_codename}-backports";
};
By default, the apt timer that updates the package list runs at 600 and 1800 hours, with a random delay of 12 hours, meaning it will run somewhere between 600 and 1800, and once more once between 1800 and and 600. I changed the random delay by creating the file /etc/systemd/system/apt-daily.timer.d/override.conf
with content
[Timer]
RandomizedDelaySec=5h
Now the packages will be updated before 1100 and before 2300. Do it twice to make sure it happens
For the package upgrades another timer is run. By default this runs at 600 horus, with a random delay of an hour. I changed the start time by creating the file /etc/systemd/system/apt-daily-upgrade.timer.d/override.conf
with content
[Timer]
OnCalendar=
OnCalendar=*-*-* 23:30
The empty OnCalendar line is on purpose to reset the OnCalendar variable. Now the packages are upgraded between 2330 and 0030.
In short:
- I ensure that apt package lists are updated before 2300 (status checks would now detect upgrades)
- Then package upgrades are run between 2330 and 0030 (status checks no longer would detect upgrades)
- The Mail in a Box status check is run at 0300, so well after packages have been upgraded.
I still get some notifications of new packages, but then a manual apt dist-upgrade
is necessary.