Friends who are accustomed to using Windows should be no strangers to automatic updates. Although the 10th generation without QA often explodes, it is still a very convenient function for server management. The Linux world is a bit different. The Ubuntu server on Azure does not enable automatic updates by default. Let's take a look at how to configure and enable automatic updates.
The version I am using is Ubuntu Server 18.10, the following method is also applicable to 18.04
01
Installation package
This package should already come with the system by default, if not, you need to install it manually:
sudoapt install unattended-upgrades
02
Configure automatic updates
Use nano to edit the configuration file:
sudonano /etc/apt/apt.conf.d/50unattended-upgrades
Uncomment the following line (remove the first double slash "//"), and change the corresponding value to true
"
Unattended-Upgrade::Mail"[email protected]";
Unattended-Upgrade::Remove-Unused-Kernel-Packages"true";
Unattended-Upgrade::Remove-Unused-Dependencies"true";
Unattended-Upgrade::Automatic-Reboot"true";
Change the Email address to your own email address so that you will receive email notifications during automatic updates.
03
Enable automatic updates
Use nano to edit files:
sudo nano/etc/apt/apt.conf.d/20auto-upgrades
Write the following file content
APT::Periodic::Update-Package-Lists"1";
APT::Periodic::Download-Upgradeable-Packages"1";
APT::Periodic::AutocleanInterval"7";
APT::Periodic::Unattended-Upgrade"1";
The 1 in Unattended-Upgrade means checking for updates every 1 day, that is, every day. This can be changed according to your needs. AutocleanInterval represents the period of automatic cleaning of useless packets.
04
test
Execute the following command to test whether the configuration is successful:
sudounattended-upgrades --dry-run --debug
05
Update log
Run the following command to view the automatic update log:
cat/var/log/unattended-upgrades/unattended-upgrades.log
// Linux is really fragrant (this line is commented, you are programmers should not see it)
Recommended Posts