Package: apt Version: 1.4.8 With sysvinit, automatic reboots issued from unattended-upgrade called by apt will interfere with other cron.daily scripts.
apt comes with a helper script /etc/cron.daily/apt-compat for doing maintenance tasks with sysvinit instead of systemd. If unattended-upgrades is also installed (I have version 0.93.1+nmu1) and Unattended-Upgrade::Automatic-Reboot is set to true in apt configuration, when a reboot is needed, a shutdown command will be issued by /usr/bin/unattended-upgrade called by /usr/lib/apt/apt.systemd.daily called by /etc/cron.daily/apt-compat. After the shutdown process is finished (i.e. during shutdown), other cron.daily scripts with names alphabetically after apt-compat are called. They may called with some essential services already stopped (which may break things), may be aborted mid-run, or may not run at all on this day. Here's how to reproduce the incorrect behaviour: apt-get install sysvinit-core unattended-upgrades shutdown -r now apt-get purge systemd cat <<EOF >/etc/apt/apt.conf.d/75local Unattended-Upgrade::Automatic-Reboot "true"; Unattended-Upgrade::Automatic-Reboot-WithUsers "true"; EOF cat <<EOF >/etc/cron.daily/z-i-am-last #!/bin/sh sleep 3600 /usr/bin/logger "z-i-am-last finished" EOF Wait for an upgrade that requires a reboot. z-i-am-last will (probably) not complete on the day of the unattended reboot. Expected behaviour: In the scenario above, z-i-am-last logs its message exactly once a day. Suggested fix: An easy way to fix this would be to rename /etc/cron.daily/apt-compat to /etc/cron.daily/zz-apt-compat to make sure this script is run after all the other daily scripts, at the same time indicating to the sysadmin that order is important. As a beneficial side effect, this would reduce the severity of things like #829443, and greatly reduce the motivation for the sysadmin to set APT::Periodic::RandomSleep to zero.