Ubuntu 20.04 Configure unattended-upgrades service

sudo vim /etc/apt/apt.conf.d/50unattended-upgrades

This file allows you to specify which packages should automatically be updated or excluded during the update process. By default, only security updates are set to be automatically installed.

The configurations in the file are commented using the double slash (//). Uncomment or remove the double slash if you want to update a repository or make changes in your settining

To exclude a package from being updated, include it in the Unattended-Upgrade::Package-Blacklist section. For example, to prevent Nginx from being updated, include the name as shown below:

It’s a wise to set up e-mail notifications, especially if you’re running unattended servers. You can also select “only-on-error” to receive notifications only when there is an error. Locate the line below to set up an email.

Unattended-Upgrade::Mail

Provide email of the recipient.

Unattended-Upgrade::Mail "me@example.com ";

In addition, you can also select “only-on-error” to receive notifications only when there is an error. Selecting email “on-change” in the configuration file allows you to receive notifications when software changes.

Uncomment the following line and change it according to your preferences. //Unattended-Upgrade::MailReport “on-change”;

//Unattended-Upgrade::Automatic-Reboot "false";

Set it to true to enable automatic reboot.

If there are any users logged in and you still want to reboot locate the following line and set it to true

Unattended-Upgrade::Automatic-Reboot-WithUsers

You can specify the time the automatic reboot will occur.

// Unattended-Upgrade::Automatic-Reboot-Time

There are many other settings you can change to suit your needs. Simply uncomment them as we have discussed in this section.

Once you are done, save the changes and exit the configuration file