brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Pick when unattended-upgrades runs by overriding apt-daily-upgrade.timer

Unattended-Upgrades
~/tips/tip-unattended-upgrades-timer-time

sudo systemctl edit apt-daily-upgrade.timer

Move the automatic upgrade run to a quiet hour of your choosing.

On Ubuntu 24.04 the upgrade run is scheduled around six in the morning with up to an hour of random delay. If that is a busy moment for you, move it.

sudo systemctl edit apt-daily-upgrade.timer

In the editor, enter:

[Timer]
OnCalendar=
OnCalendar=*-*-* 03:30
RandomizedDelaySec=15m

The empty OnCalendar= line matters. It clears the times from the original unit, and without it your time is added next to the old one. Check the result:

systemctl list-timers apt-daily-upgrade.timer

The download of package lists has its own timer, apt-daily.timer, which runs twice a day with a long random delay. The upgrade step uses what has been fetched by then.

I keep a bit of random delay so that many machines do not hit the mirror in the same second.

The timer has Persistent=true, so a machine that was off at 03:30 runs the job shortly after it starts, possibly in the middle of your working day. And if you also let unattended-upgrades reboot, pick that reboot time after this one, with enough room for a large upgrade to finish.

Further reading: systemd.timer man page, unattended-upgrades README

More Unattended-Upgrades tips sudo nano /etc/apt/apt.conf.d/52unattended-upgrades-local apt-cache policy cat /etc/apt/apt.conf.d/20auto-upgrades Unattended-Upgrade::Mail "[email protected]"; Unattended-Upgrade::Automatic-Reboot "true"; All Unattended-Upgrades tips (7) All topics

Link