sudo apt-get install unattended-upgrades update-notifier-common
To enable it, do:
sudo dpkg-reconfigure -plow unattended-upgrades
(it’s an interactive dialog) which will create /etc/apt/apt.conf.d/20auto-upgrades with the following contents:
APT::Periodic::Update-Package-Lists “1”;
APT::Periodic::Unattended-Upgrade “1”;
to make sure that the server reboots after an important upgrade you need to adjust a line in
/etc/apt/apt.conf.d/50unattended-upgrades
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
make sure this line is set to true and not commented out:
Unattended-Upgrade::Automatic-Reboot "true"
be aware that this could cause some issues, if for example you running a webshop and someone is making an order
this could be a disaster that you reboot the server in the middle of the order. To avoid this
I recommend doing updates manually and under control about visitors on your site.