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.
Provide email of the recipient.
Unattended-Upgrade::Mail "firstname.lastname@example.org ";
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”;
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
You can specify the time the automatic reboot will occur.
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