Debian – Unattended Upgrades failing

aptdebianunattended-upgrades

I keep getting this error on apt-get upgrade:

Installing unattended-upgrades (0.93.1+nmu1) ...
Failed to start unattended-upgrades.service: Unit unattended-upgrades.service failed to load: Invalid argument. See system logs and 'systemctl status unattended-upgrades.service' for details.
invoke-rc.d: initscript unattended-upgrades, action "start" failed.
● unattended-upgrades.service - Unattended Upgrades Shutdown
   Loaded: error (Reason: Invalid argument)
   Active: inactive (dead)
     Docs: man:unattended-upgrade(8)

jun 06 18:29:32 PRODUCTION systemd[1]: unattended-upgrades.service lacks ExecStart setting. Refusing.
jun 06 18:29:32 PRODUCTION systemd[1]: unattended-upgrades.service lacks ExecStart setting. Refusing.
jun 06 18:29:32 PRODUCTION systemd[1]: unattended-upgrades.service lacks ExecStart setting. Refusing.
jun 06 18:32:41 PRODUCTION systemd[1]: unattended-upgrades.service lacks ExecStart setting. Refusing.
jun 06 18:32:41 PRODUCTION systemd[1]: unattended-upgrades.service lacks ExecStart setting. Refusing.
jun 06 18:32:41 PRODUCTION systemd[1]: unattended-upgrades.service lacks ExecStart setting. Refusing.
jun 06 18:32:41 PRODUCTION systemd[1]: unattended-upgrades.service lacks ExecStart setting. Refusing.
jun 06 18:33:24 PRODUCTION systemd[1]: unattended-upgrades.service lacks ExecStart setting. Refusing.
jun 06 18:33:24 PRODUCTION systemd[1]: unattended-upgrades.service lacks ExecStart setting. Refusing.
jun 06 18:33:24 PRODUCTION systemd[1]: unattended-upgrades.service lacks ExecStart setting. Refusing.
dpkg: erro ao processar o pacote unattended-upgrades (--configure):
 subprocesso script post-installation returned exit status code 6
Errors were found while processing:
 unattended-upgrades
E: Sub-process /usr/bin/dpkg returned an error code (1)

I don't care about unattended-upgrades, it can be removed. I tried apt-get remove but no luck there:

Removing unattended-upgrades (0.93.1+nmu1) ...
Failed to stop unattended-upgrades.service: Unit unattended-upgrades.service not loaded.
invoke-rc.d: initscript unattended-upgrades, action "stop" failed.
dpkg: error processing package unattended-upgrades (--remove):
 subprocess script pre-removal returned exit status error 5
Errors were found while processing:
 unattended-upgrades
E: Sub-process /usr/bin/dpkg returned an error code (1)

The messages have been translated as some of them were not in english.

I have debian jessie with sid repository configured.

uname -a:
Linux PRODUCTION 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2 (2017-04-30) x86_64 GNU/Linux

cat /etc/debian_version:
9.0

I just want that nasty error gone, I don't care how. either by removing the package or fixing the issue, but I don't seem to be able to remove it, nor am I able to fix it due to lack of knowledge 🙂

Any hint?

Best Answer

systemctl mask unattended-upgrades

Explanation:

systemd units can be overridden by the adminstrator putting a file with the same name in /etc/systemd/system.

This mechanism can also be used to "mask" a service from being activated by socket activation, manual starts, or any other method. Instead of creating a file with the same name, if there is a symbolic link to /dev/null, then the unit is effectively ignored.

So you can ab(use) systemctl mask, to replace the contents of the unit with nothing.

To avoid the possibility confusion in future, check that you remove the mask once you have removed the package. systemctl unmask unattended-upgrades.

Related Question