-
Install
unattended-upgrades
librarysudo apt install -y unattended-upgrades
-
Configurate
unattended-upgrades
servicesudo nano /etc/apt/apt.conf.d/50unattended-upgrades
Define updates you want to manage within the files. For example, to enable automatic security updates, make sure you have a different and correctly set section as follows:
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"; };
-
Setting up automatic boot
sudo nano /etc/apt/apt.conf.d/20auto-upgrades
Set the configuration below within the file
APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1"; APT::Periodic::AutocleanInterval "7"; Unattended-Upgrade::Remove-Unused-Dependencies "true"; Unattended-Upgrade::Remove-New-Unused-Dependencies "true"; # This is the most important choice: auto-reboot. Unattended-Upgrade::Automatic-Reboot "true"; Unattended-Upgrade::Automatic-Reboot-Time "02:00";
-
Process the changes by restarting teh service
sudo systemctl restart unattended-upgrades
-
Check the service with a forced start
sudo unattended-upgrade -d
Unattended Upgrades on Ubuntu Server
Enable Automatic Security Updates on Ubuntu Server.