Automating Ubuntu 14.04 Automatic Updates

sudo dpkg-reconfigure unattended-upgrades

If you receive an error stating that unattended-upgrades package cannot be found, then run the command below. Otherwise skip to the next section.

sudo apt-get update
sudo apt-get install -y unattended-upgrades

The command above will install (or reinstall) the package and any other required dependencies.

To change the time that updates run, you'll need to update the crontab for this job. Run the command

sudo vi /etc/crontab

Find the line that contains

15 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

and change it to

15 2    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

Then save the crontab file and exit.

If you want to view the automatic update history, you can view the Unattended Upgrades log file by going to the log directory

cd /var/log/unattended-upgrades/

Here you will have the log files for the updates that were performed.

root@pbook:/var/log/unattended-upgrades# ls
unattended-upgrades-dpkg_2016-02-23_06:53:08.139255.log  unattended-upgrades-dpkg_2016-03-02_06:45:32.549847.log  unattended-upgrades.log
unattended-upgrades-dpkg_2016-02-25_06:37:04.235617.log  unattended-upgrades-dpkg_2016-03-03_06:51:24.794181.log  unattended-upgrades.log.1.gz
unattended-upgrades-dpkg_2016-02-27_06:47:23.014962.log  unattended-upgrades-dpkg_2016-03-10_06:44:05.855211.log  unattended-upgrades-shutdown.log

Additional options related to the Unattended Upgrades including automatic reboot and sending email notifications can be found in /etc/apt/apt.conf.d/50unattended-upgrades

Published: 2016-03-10
Updated: 2020-07-15
Category: Technology
Read Time: 1 minute(s)