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: let unattended-upgrades reboot at 04:00 instead of never

Unattended-Upgrades
~/tips/tip-ubuntu-unattended-upgrades-reboot-time

Unattended-Upgrade::Automatic-Reboot "true";

Makes automatic updates restart the machine at a fixed night time when a reboot is needed.

Kernel updates install fine on their own. They do nothing until the machine restarts, and by default unattended-upgrades never restarts it.

Two lines in /etc/apt/apt.conf.d/50unattended-upgrades change that:

Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";

The docs say Automatic-Reboot defaults to false, and that when it is on the machine reboots at the end of a run if one is needed, without asking. The time defaults to now, so setting hh:mm in local time keeps the restart out of your working day. A +m minute offset works too.

You can see whether a restart is pending by looking for the flag file:

ls /var/run/reboot-required

On a home server I would turn this on and stop thinking about it. On anything that serves other people, I would first make sure the services come back by themselves after a boot.

The file also lists which origins count as safe to install on their own, so give it a look while you have it open.

Caveat: without asking means without asking. A long job running at 04:00 dies with the restart.

Further reading: Ubuntu Server docs: Automatic updates, On this site: do a dry run before you trust unattended-upgrades

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]"; sudo systemctl edit apt-daily-upgrade.timer All Unattended-Upgrades tips (7) All topics

Link