unattended-upgrades do not work properly

7,945

Solution 1

Contrary to the answer above my: "/etc/apt/apt.conf.d/50unattended-upgrades" did have:

Unattended-Upgrade::InstallOnShutdown "false";

Yet I still was seeing:

Welcome to Ubuntu 18.04.3 LTS (GNU/Linux [...] x86_64)
[...]
29 packages can be updated.
0 updates are security updates.

So why were these 29 packages not updated?

As it turns out, "/etc/apt/apt.conf.d/50unattended-upgrades" also contained this declaration:

Unattended-Upgrade::Allowed-Origins {
        "${distro_id}:${distro_codename}";
        "${distro_id}:${distro_codename}-security";
        // Extended Security Maintenance; doesn't necessarily exist for
        // every release and this system may not have it installed, but if
        // available, the policy for updates is such that unattended-upgrades
        // should also install from here by default.
        "${distro_id}ESM:${distro_codename}";
//      "${distro_id}:${distro_codename}-updates";
//      "${distro_id}:${distro_codename}-proposed";
//      "${distro_id}:${distro_codename}-backports";
};

The key to a fix for me was simply to uncomment this line:

//      "${distro_id}:${distro_codename}-updates";

Solution 2

I found the reason:

Unattended-Upgrade::InstallOnShutdown "true";

This means that updates are only installed before a shutdown. Since I this machine is a 24/7 server updates never happened.

Solution 3

If it's still not working after following this answer by @cuedee, you can try doing a dry run and see if you get some sort of error message or warning.

sudo unattended-upgrades -v -d

In my case the output explained that my connection was metered (hotspot from mobile phone), and unattended-upgrades by default doesn't allow updates over metered connections. I changed it with the following line in /etc/apt/apt.conf.d/50unattended-upgrades:

Unattended-Upgrade::Skip-Updates-On-Metered-Connections "false";
Share:
7,945

Related videos on Youtube

Thomas Aichinger
Author by

Thomas Aichinger

Updated on September 18, 2022

Comments

  • Thomas Aichinger
    Thomas Aichinger over 1 year

    I have

    Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.15.0-24-generic x86_64)
    
    15 packages can be updated.
    7 updates are security updates.
    

    I watched this several weeks and tried so many things to fix it, but I cant get it run. Unattended-upgrades do not upgrade my server.

    I installed

    # apt-get install unattended-upgrades
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    unattended-upgrades is already the newest version (0.90ubuntu0.9).
    0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
    
    # apt-get install apt-listchanges
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    apt-listchanges is already the newest version (2.85.14ubuntu1).
    0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
    

    This is my /etc/apt/apt.conf.d/10periodic

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

    This is my /etc/apt/apt.conf.d/50unattended-upgrades

    Unattended-Upgrade::Allowed-Origins {
            "${distro_id}:${distro_codename}";
            "${distro_id}:${distro_codename}-security";
            "${distro_id}ESM:${distro_codename}";
            "${distro_id}:${distro_codename}-updates";
    };
    
    Unattended-Upgrade::Package-Blacklist {
            "open-vm-tools";
    };
    
    Unattended-Upgrade::AutoFixInterruptedDpkg "true";
    Unattended-Upgrade::MinimalSteps "true";
    Unattended-Upgrade::InstallOnShutdown "true";
    Unattended-Upgrade::Mail "root";
    Unattended-Upgrade::MailOnlyOnError "true";
    Unattended-Upgrade::Remove-Unused-Dependencies "true";
    Unattended-Upgrade::Automatic-Reboot "true";
    Unattended-Upgrade::Automatic-Reboot-Time "07:00";
    Acquire::http::Dl-Limit "0";
    

    This is what I have in log-file /var/log/unattended-upgrades/unattended-upgrades.log

    INFO Initial blacklisted packages: open-vm-tools
    INFO Initial whitelisted packages:
    INFO Starting unattended upgrades script
    INFO Allowed origins are: ['o=Ubuntu,a=xenial', 'o=Ubuntu,a=xenial-security', 'o=UbuntuESM,a=xenial', 'o=Ubuntu,a=xenial-updates']
    INFO Initial blacklisted packages: open-vm-tools
    INFO Initial whitelisted packages:
    INFO Starting unattended upgrades script
    INFO Allowed origins are: ['o=Ubuntu,a=xenial', 'o=Ubuntu,a=xenial-security', 'o=UbuntuESM,a=xenial', 'o=Ubuntu,a=xenial-updates']
    

    Does anyone have a clue what is wrong?

  • NoOne
    NoOne over 2 years
    From my understanding, by default, only the security updates are installed automatically. This can prevent unwanted surprises sometimes.
  • NoOne
    NoOne over 2 years
    For me, running sudo unattended-upgrades -v -d works fine and all security updates get installed. Yet, when I leave the service to auto-update my machine, it does nothing! I can see that the unattended-upgrades.service service status is active (running). Only a warning is appearing: Warning: some journal files were not opened due to insufficient permissions.. So, go figure... I will try to check cat /var/log/unattended-upgrades/unattended-upgrades.log next time.