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}-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



2 thoughts 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.

  2. purvez desai says:

    Thanks very much for a well laid out set of instructions. However I have a question please.

    I’ve recently upgraded to 16.04 and want to start using auto unattended security upgrades. I currently don’t have a 10periodic file at all in /etc/apt/apt.conf.d/ although I do have a 50unattended-upgrades. Looking at the /etc/cron.daily directory it has an apt-compat which wants to incorporate random time delays before calling /usr/lib/apt/apt.systemd.daily.

    My question is will the creation of a 10periodic automatically override the apt-compat random time delays or would I still have to do something else?

    All advice gratefully received with thanks.

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s