Unattended Upgrades on Linux

This example uses Raspbian, but it should work on many Debian and Ubuntu based systems also. First update the repositories and upgrade your system. Afterwards install the package unattended-upgrades and its dependencies.

Installing unattended-upgrades should look like this:

pi@pizero: ~ $ sudo apt update
pi@pizero: ~ $ sudo apt upgrade
pi@pizero: ~ $ sudo apt install unattended-upgrades

  Paketlisten werden gelesen... Fertig
  Abhängigkeitsbaum wird aufgebaut.
  Statusinformationen werden eingelesen... Fertig

  Die folgenden zusätzlichen Pakete werden installiert:
  python3-dbus python3-distro-info python3-gi

  Vorgeschlagene Pakete:
  python-dbus-doc python3-dbus-dbg bsd-mailx default mta
  mail-transport-agent needrestart powermgmt-base python3-dbus
  python3-distro-info python3-gi unattended-upgrades

  0 aktualisiert, 4 neu installiert, 0 zu entfernen und 0 nicht
  aktualisiert.

  Es müssen 344kB an Archive heruntergeladen werden.
  Nach dieser Operation werden 1'608kB Plattenplatz
  zusätzlich benutzt.

  Möchten Sie fortfahren? [J/n] j

When the installation’s finished you should run sudo dpkg-reconfigure -plow unattended-upgrades and check the cron file /etc/apt/apt.conf.d/20auto-upgrades if it contains at least the following two lines:

pi@pizero: ~ $ sudo dpkg-reconfigure -plow unattended-upgrades sudo dpkg-reconfigure -plow unattended-upgrades
pi@pizero: ~ $ sudo cat /etc/apt/apt.conf.d/20auto-upgrades
  APT::Periodic::Update-Package-List "1";
  APT::Periodic::Unattended-Upgrade "1";

You should check /etc/apt/apt.conf.d/02periodic also and change or add some lines if necessary. I changed it to a minimum of things it should do and stopped it from sending emails every day unattended upgrades are carried out.

pi@pizero: ~ $ sudo cat /etc/apt/apt.conf.d/02periodic
  // Enable the update/upgrade script (0=disable)
  APT::Periodic::Enable "1";

  // Do "apt-get autoclean" every n-days (0=disable)
  APT::Periodic::AutocleanInterval "21";

  // Send report mail to root
  // 0: no report (or null string)
  // 1: progress report (actually any string)
  // 2: + command outputs (remove -qq, remove 2>/dev/null, add -d)
  // 3: + trace on
  APT::Periodic::Verbose "0";

Last thing to do, check logrotate if you don´t want to end with a single log worth of gigabytes of text from month or even years back. You should find or create a file like this. Tweak it as you like (e.g. mine rotates 7 times on a daily basis):

pi@pizero: ~ $ cat /etc/logrotate.d/unattended-upgrades
  /var/log/unattended-upgrades/*.log    {
      rotate 6
      monthly
      compress
      missingok
      notifempty
    }
pi@pizero: ~ $ sudo dpkg-reconfigure --priority=low unattended-upgrades