Package: unattended-upgrades
Version: 1.11.2
Severity: normal
Hi!
There are several systems where I get
Date: Tue, 15 Jun 2021 06:00:17 +0200
From: Cron Daemon
Subject: Cron <root@dom> test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
/etc/cron.daily/logrotate:
invoke-rc.d: -----------------------------------------------------
invoke-rc.d: WARNING: 'invoke-rc.d rsyslog rotate' called
invoke-rc.d: during shutdown sequence.
invoke-rc.d: enabling safe mode: initscript policy layer disabled
invoke-rc.d: -----------------------------------------------------
whenever unattended-upgrades needs to reboot. *Before* the
reboot the system looks like this:
root 835 0.0 0.0 8504 2336 ? Ss Jun15 0:00 /usr/sbin/cron
root 12595 0.0 0.0 9120 2316 ? S 06:25 0:00 \_ /usr/sbin/CRON
root 12596 0.0 0.0 2388 700 ? Ss 06:25 0:00 \_ /bin/sh -c test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
root 12597 0.0 0.0 2284 688 ? S 06:25 0:00 \_ run-parts --report /etc/cron.daily
root 12598 0.0 0.0 2388 764 ? S 06:25 0:00 \_ /bin/sh /usr/lib/apt/apt.systemd.daily
root 12733 0.0 0.0 2388 1488 ? S 06:41 0:00 \_ /bin/sh /usr/lib/apt/apt.systemd.daily lock_is_held
root 13047 0.0 0.2 123308 34548 ? Sl 06:41 0:00 \_ /usr/bin/python3 /usr/bin/unattended-upgrade
root 13057 0.0 0.0 2372 1752 ? S 06:41 0:00 \_ /sbin/shutdown -r 06:00
In human language: this morning at 06:25 cron.daily ran,
which triggered unattended-upgrades, which triggered
`/sbin/shutdown -r 06:00`.
Now one problem here is that `/sbin/shutdown -r 06:00` is
actually blocking. It will *not* exit, but instead will
count waiting time to zero and reboot after.
We are on a system with `sysv-rc` and not `systemd`. I have
*not* verified whether `shutdown -r $TIME` behavior is
identical on a `systemd` system.
The system apparently shut down at:
# cat /var/log/messages
Jun 15 06:00:14 dom shutdown[13634]: shutting down for system reboot
also
# cat /var/log/daemon.log
Jun 15 06:00:15 dom init: Switching to runlevel: 6
also
# last -F
reboot system boot 4.19.0-16-amd64 Tue Jun 15 06:00:28 2021 - Wed Jun 16 10:34:57 2021 (1+04:34)
So my interpretation is this:
1. cron.daily runs
2. it executes unattended-upgrade
3. unattended-upgrade blocks when it calls shutdown -r 06:00
4. in our case that stops the other cron.daily tasks that are
sorted after /etc/cron.daily/apt-compat (that is pretty
much all others since apt-compat is first in the alphabet)
from running
5. the clock hits 06:00:00 and shutdown exits (this is my
guess - I think it's the same behavior as with
`shutdown -r now` which also exits and so you sometimes
see/get back to the prompt before the sytstem *actually*
warm reboots)
6. after `shutdown -r 06:00` exits unattended-upgrade
finishes whatever it was doing, exits and cron.daily continues
with the execution with the other scripts in /etc/cron.daily/
that alphabetically follow apt-compat, which makes a
mess, because we're actually in runlevel 6/shutdown
now. which triggers the warning we saw above from
logrotate/cron.
Now what would a "correct" or "better" behavior be?
I suggest to trigger an asynchronous shutdown, that is *not*
to wait for `shutdown -r $TIME` to come back so that whatever
daily menial taks are scheduled via /etc/cron.daily are able
to be executed.
In other words: fork & exec shutdown...
?
Thanks a lot for maintaining unattended-upgrades!!!! Greetings,
*t
-- System Information:
Debian Release: 10.9
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 4.19.0-16-amd64 (SMP w/8 CPU cores)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE=C (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
Versions of packages unattended-upgrades depends on:
ii debconf [debconf-2.0] 1.5.71
ii lsb-base 10.
2019051400
ii lsb-release 10.
2019051400
ii python3 3.7.3-1
ii python3-apt 1.8.4.3
ii python3-dbus 1.2.8-3
ii python3-distro-info 0.21
ii ucf 3.0038+nmu1
ii xz-utils 5.2.4-1
Versions of packages unattended-upgrades recommends:
ii cron [cron-daemon] 3.0pl1-134+deb10u1
Versions of packages unattended-upgrades suggests:
ii bsd-mailx 8.1.2-0.20180807cvs-1
pn needrestart <none>
ii nullmailer [mail-transport-agent] 1:2.2-3
pn powermgmt-base <none>
ii python3-gi 3.30.4-1
-- debconf information:
* unattended-upgrades/enable_auto_updates: true
unattended-upgrades/origins_pattern: "origin=Debian,codename=${distro_codename},label=Debian-Security";