Automatic Updates on Ubuntu
Consider wisely, if you really want this, as it can result in unexpected behavior. I do this for a notebook which I don’t depend on and backup regularly. Also I usually do updates without looking into to the installing packages for this machine anyway…
Prerequisites
Check if the necessary service is up and running:
systemctl status unattended-upgrades |
(This should be the case on default Ubuntu installations, if not do a sudo apt install unattended-upgrades
.)
Configuration
Edit the file /etc/apt/apt.conf.d/50unattended-upgrades
with root to configure what and how the auto-upgrades happen:
- In the first block
Unattended-Upgrade::Allowed-Origins
remove the line comments for the package types that you want to have installed automatically. By default, onlysecurity
andESM
are enabled. - (Optional) Add any packages that you don’t want to install automatically to the blacklist block
Unattended-Upgrade::Package-Blacklist
. Useful for packages that restart/quit during upgrades. - (Optional) Uncomment
Unattended-Upgrade::AutoFixInterruptedDpkg "true"
to try an autofix in case of interrupted upgrades. - (Optional) Uncomment
Unattended-Upgrade::MinimalSteps "true";
to make the upgrades more robust against e.g. user reboots during upgrades. - (Optional) Uncomment and configure
Acquire::http::Dl-Limit "500";
to limit the network bandwidth for the updates. I like setting this to a third of my available internet speed, so I barely notice the upgrades.
Edit /etc/apt/apt.conf.d/20auto-upgrades
with root to define how often the upgrade gets started:
- To upgrade daily, set
APT::Periodic::Update-Package-Lists "1";
andAPT::Periodic::Unattended-Upgrade "1";
- If you want to do additional weekly cleanup, you can add as third line
APT::Periodic::AutocleanInterval "7";
.