Ubuntu 18.10 - Unattended-upgrades-shutdown --wait-for-signal

It's a safety feature. Leave it alone.

Apt data (packages and metadata) can be corrupted if apt happens to be running when the system halts (shuts down). The unattended-updates-shutdown script temporarily inhibits a shutdown signal until apt finishes.

The script cannot prevent corruption due to a sudden power loss, or holding the power button, while apt happens to be running. Another reason to avoid those, and to keep regular backups.

The script is in Python, including the developer's comments. Feel free to read it and see for yourself.


I ran into this same issue recently as well, while checking for unattended-upgrades running in the background during my image baking process. Basically, I would wait for apt locks to be released, then proceed with my updates.

I used to run this:

while pgrep unattended; do sleep 10; done;

before executing any of my scripts as they would randomly fail at some odd intervals with unattended-upgrades running while me trying to do apt install/upgrade/update with a dpkg lock error.

So I asked for the right way to check for unattended upgrades working in the background and TJ- from IRC gave me a really elegant solution! Disable the u-u service whilst bootstrap scripts are busy. As in:

systemctl mask unattended-upgrades.service
systemctl stop unattended-upgrades.service

then re-enable after you finish your bake:

systemctl unmask unattended-upgrades.service
systemctl start unattended-upgrades.service

In addition, you can run this to make sure you don't kick off your process prematurely:

while systemctl is-active --quiet unattended-upgrades.service; do sleep 1; done

Probably not what you were looking for but this was extremely helpful for me. This might be related to: https://bugs.launchpad.net/ubuntu/+source/unattended-upgrades/+bug/1803137