How to Schedule Automatic Updates on Ubuntu Server 16.04

If is not there install unattended-upgrade package:

sudo apt-get install unattended-upgrades

or simply reconfigure the package:

sudo dpkg-reconfigure unattended-upgrades

If needed, configure the proxy for apt:

 echo ‘Acquire::http::Proxy “http://%5B2001:db8:abcd:3f0d::1]:8123/”;’ | sudo tee –append /etc/apt/apt.conf

Then edit /etc/apt/apt.conf.d/10periodic configuring when update, upgrade and autoclean should run:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "7";
APT::Periodic::AutocleanInterval "14";
APT::Periodic::Unattended-Upgrade "7";

Edit /etc/apt/apt.conf.d/50unattended-upgrades changing the setting for what kind of update you what to apply and when the machine should reboot:

// Automatically upgrade packages from these (origin:archive) pairs
Unattended-Upgrade::Allowed-Origins {
        "${distro_id}:${distro_codename}-security";
        "${distro_id}:${distro_codename}-updates";
//      "${distro_id}:${distro_codename}-proposed";
//      "${distro_id}:${distro_codename}-backports";
};

// Automatically reboot *WITHOUT CONFIRMATION*
//  if the file /var/run/reboot-required is found after the upgrade
Unattended-Upgrade::Automatic-Reboot "true";

// If automatic reboot is enabled and needed, reboot at the specific
// time instead of immediately
//  Default: "now";
Unattended-Upgrade::Automatic-Reboot-Time "02:00";

If you what to run unattended-upgrade one a week only for example on Saturday…

touch -t 201608200200 /var/lib/apt/periodic/upgrade-stamp

Via: https://help.ubuntu.com/16.04/serverguide/automatic-updates.html
https://help.ubuntu.com/community/AutoWeeklyUpdateHowTo
http://serverfault.com/questions/454510/debian-running-unattended-upgrades-on-a-particular-day-of-the-week/547740

Advertisements

One thought on “How to Schedule Automatic Updates on Ubuntu Server 16.04

  1. Simon Singh says:

    Thanks, was looking for this, can also add email address in Unattended-Upgrade::Mail field in /etc/apt/apt.conf.d/50unattended-upgrades. Will find out if it works.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s