Unattended Upgrades
Table of Contents
1. Description
Some notes on installing and configuring unattended-upgrades.
Unattended Upgrades is needed for installing updates automatically but
not if we only want to run apt update automatically (or downloading
upgradable packages automatically), see apt.systemd.daily shell script
for more info.
Files timestamp in /var/lib/apt/periodic/ are updated when the
script is triggered by its systemd timer apt-daily.timer.
The software-properties GUI has an “Updates” tab to control how
updates are handled when the unattended-upgrades package is
installed.
2. Installation
sudo apt install unattended-upgrades
The powermgmt-base package is required for AC/battery options
(e.g. Unattended-Upgrade::OnlyOnACPower).
3. Configuration
- https://github.com/mvo5/unattended-upgrades/blob/master/data/50unattended-upgrades.Debian
- https://manpages.debian.org/stable/apt/apt.conf.5
The default configuration file is at
/etc/apt/apt.conf.d/50unattended-upgrades.
To override the default configuration file it is recommended to create
another apt configuration file to prevent package updates conflicting
with local changes, blocking unattended-upgrades itself.
The new file has to be parsed after 50unattended-upgrades to
override it (apt reads files in /etc/apt/apt.conf.d/ in lexical
order) so name it, e.g. /etc/apt/apt.conf.d/51unattended-upgrades-local.
# /etc/apt/apt.conf.d/51unattended-upgrades-local Unattended-Upgrade::Origins-Pattern { "origin=Debian,codename=${distro_codename}-updates"; "origin=Debian,codename=${distro_codename},label=Debian"; "origin=Debian,codename=${distro_codename},label=Debian-Security"; "origin=Debian,codename=${distro_codename}-security,label=Debian-Security"; }; Unattended-Upgrade::AutoFixInterruptedDpkg "true"; Unattended-Upgrade::Remove-Unused-Kernel-Packages "true"; Unattended-Upgrade::Automatic-Reboot "true"; Unattended-Upgrade::Automatic-Reboot-Time "17:00";
4. Enable
sudo dpkg-reconfigure -plow unattended-upgrades
You can also create a file in /etc/apt/apt.conf.d/ to enable and
configure when updates are automatically installed, see
notes:apt#periodic-updates.
5. Current configuration
The current configuration can be queried with apt-config (see
notes:apt-config).
apt-config dump APT::Periodic::Unattended-Upgrade
If it returns APT::Periodic::Unattended-Upgrade "1"; then
unattended-upgrades is enabled.
6. Logs
All operations are logged in /var/log/unattended-upgrades/, packages
upgrades are also logged in /var/log/apt/history.log.
7. Related nodes
8. References
- https://github.com/mvo5/unattended-upgrades
- https://tracker.debian.org/pkg/unattended-upgrades
- https://wiki.debian.org/UnattendedUpgrades
- https://help.ubuntu.com/community/AutomaticSecurityUpdates
- https://www.debian.org/doc/manuals/debian-reference/ch02.en.html#_automatic_download_and_upgrade_of_packages
- https://debian-handbook.info/browse/stable/sect.regular-upgrades.html