大网数据广告活动
服务器运维问答

In Debian-based script: how to determine if kernel changed and needs reboot?

· 52CE 我爱测

How can we (more) easily determine if a kernel-change-reboot is required in Debian, other than doing this in a script (which is a bit cumbersome)? Ubuntu has /var/run/reboot-required and per our experience it works well. However,…

问题原文

原帖链接 · Johnny Utahh · CC BY-SA 4.0

How can we (more) easily determine if a kernel-change-reboot is required in Debian, other than doing this in a script (which is a bit cumbersome)?

Ubuntu has /var/run/reboot-required and per our experience it works well. However, thus far Debian (at least in Buster, 10.6) does not. Some package(s) might have done this in the past (prior to Debian Jessie) and were replaced thigns that try/claim to do it today, but we've seen nothing work (in 10.6). Details below.

Things we've tried (in Debian 10.6) with no success:

  1. checkrestart (no simple binary state report for kernel boot)
  2. needrestart (same problem as #1)
  3. Despite https://serverfault.com/a/667082/104173 claiming so, /var/run/reboot-required.pkgs has not yet been visible on our Debian 10.6 system (after a kernel upgrade).
  4. reboot-notifier does not seem to offer anything that works.
  5. lsof | grep lib | grep DEL does not (yet) seem to provide what we need.

"Nagios output mode" for some of the above options do not (yet) seem easily parsable.

已采纳解答

原帖链接 · gxx · CC BY-SA 4.0

What about checking the return code? needrestart -k -p > /dev/null; echo $? gives 0 for an up-to-date kernel, and 2 if the running kernel is not the expected one.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-12-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。