Here is a method to set up automatic updates on your Ubuntu server, avoiding the need to manually check and apply important security updates and patches.
Start by updating your package information:
sudo apt update
Next install unattended-upgrades
sudo apt install unattended-upgrades apt-listchanges bsd-mailx
Enable the unattended security updates with:
sudo dpkg-reconfigure -plow unattended-upgrades
Now to configure some settings for the automatic updates
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
Ensure the following is set/edited:
Unattended-Upgrade::Mail "YOUREMAIL@email.com";
Unattended-Upgrade::Automatic-Reboot "true";
This ensures the email logs will be sent to and allow for automatic reboots.
Save and exit the file.
Next go to:
sudo nano /etc/apt/listchanges.conf
and set your email again like so:
email_address=YOUREMAIL@email.com
Save and exit the file.
You can verify that the automatic updates is working by running:
sudo unattended-upgrades --dry-run
Whenever new updates are downloaded and installed you will be emailed a log with details. Alternatively you can use
sudo tail -f /var/log/unattended-upgrades/unattended-upgrades.log
To check the logs.