Set up automatic unattended updates for Ubuntu 20.04

ww‮ual.w‬tturi.com
Set up automatic unattended updates for Ubuntu 20.04

To set up automatic unattended updates for Ubuntu 20.04, you will need to install the unattended-upgrades package and configure it to automatically download and install security updates.

First, update the package list and install the unattended-upgrades package using the apt-get command:

sudo apt-get update
sudo apt-get install unattended-upgrades

Next, edit the /etc/apt/apt.conf.d/50unattended-upgrades file and set the Unattended-Upgrade option to 1 to enable automatic updates:

Unattended-Upgrade "1";

By default, the unattended-upgrades package will only install security updates. If you want to install other types of updates, such as bug fixes and feature updates, you can edit the /etc/apt/apt.conf.d/50unattended-upgrades file and uncomment the appropriate lines. For example, to install all updates, you can uncomment the following line:

"${distro_id}:${distro_codename}";

To configure automatic updates to run at a specific time, you can use the cron daemon to schedule a daily job. Edit the /etc/cron.daily/apt-compat file and add the following line to run updates at 4:00 AM every day:

0 4 * * * root test -x /usr/sbin/unattended-upgrade && /usr/sbin/unattended-upgrade -d

To apply the changes, restart the cron daemon:

sudo service cron restart

You can use the unattended-upgrade command to manually run updates at any time:

sudo unattended-upgrade

Keep in mind that automatic updates can potentially cause disruptions or breakages if they install incompatible updates. You should carefully review the updates that will be installed and test them in a staging environment before deploying them in a production environment. You can also use the --dry-run option to simulate the update process without actually installing any updates.

sudo unattended-upgrade --dry-run
Created Time:2017-10-30 14:27:18  Author:lautturi