我在我的Ubuntu系统上设置了
unattended-upgrade
。偶尔我会远程登录其中一个系统,然后看到一条消息告诉我需要重新启动系统(以完成升级)。有没有办法确定是哪个特定的软件包(或一组软件包)触发了这个通知?unattended-upgrade
。偶尔我会远程登录其中一个系统,然后看到一条消息告诉我需要重新启动系统(以完成升级)。有没有办法确定是哪个特定的软件包(或一组软件包)触发了这个通知?cat /var/run/reboot-required.pkgs
解释:
看起来有一种简单的方法可以自动提取所需的信息。
.deb
文件中包含了安装的控制文件,其中包括 postinst
(安装后运行)。
例如,在 linux-image-2.6.35-25-generic_2.6.35-25.44_amd64.deb
中,
postinst
包含以下内容:
my $notifier = "/usr/share/update-notifier/notify-reboot-required";
my $warn_reboot = 'Yes'; # Warn that we are installing a version of
# the kernel we are running
并且
# Warn of a reboot
if (-x $notifier) {
system($notifier);
}
/usr/share/update-notifier/notify-reboot-required
会更新 /var/run/reboot-required
和 /var/run/reboot-required.pkgs
。unattended-upgrades
发现存在/var/run/reboot-required
文件时,建议重新启动。该文件是由某些软件包中的postinst
(安装后)脚本创建的,它看起来像这样:[ -x /usr/share/update-notifier/notify-reboot-required ] && \
/usr/share/update-notifier/notify-reboot-required || true
/var/run/reboot-required.pkgs
文件的内容。~$ mkdir debs
~$ cd debs
~/debs$ apt-get download $(dpkg -l | tail -n +7 | awk '{print $2}')
~/debs$ for x in $(ls); do y=$(dpkg-deb -I "$x" postinst 2>/dev/null | grep 'reboot-required'); if [ -n "$y" ]; then echo "$x" | grep -Poe '^.*?(?=_)'; fi; done
dbus
gconf2
initscripts
libc6
libpam0g
libpam-systemd
libssl1.0.0
linux-image-3.19.0-47-generic
linux-image-3.19.0-49-generic
network-manager
upstart
grep -l reboot-required /var/lib/dpkg/info/*.postinst | sed -e 's,^.*/\(.*\)\.postinst,\1,'
完成相同的操作,而无需进行任何繁琐的下载。但请注意,它仅会报告可能在某个时候需要重新启动的软件包,而不是此次实际上需要重新启动的软件包。 - Matija Nalis
/var/run/reboot-required
是在一天之前创建的,但在Ubuntu 16.04.5 LTS中没有/var/run/reboot-required.pkgs
文件。 - Lion