When you manage Linux systems it's usually pretty clear how to reboot a system. But do you know how to check whether a system requires a reboot? Cause you don't want to reboot a system if it is not necessary
Debian-based systems
There are some posts out there which talks about this topic. Check for a required reboot on Debian and Ubuntu systems is an interesting one which speaks about a /var/run/reboot-required.pkgs
.
I actually don’t fine anything about the reboot-required
file or mechanism in the Debian documentation but only on the UbuntuNotifier documentation
However, the UbuntuNotifier is not very specific and also refers to /var/run/reboot-required
and not /var/run/reboot-required.pkgs
.
What creates the file /var/run/reboot-required
I ask the same question but as mentioned I don’t find anything in the official documentation, but only on this Reddit post:
On Debian-like systems it’s created by
/usr/share/update-notifier/notify-reboot-required
which is called in the.postinst
script of some packages.
On my Debian Buster I don’t have /usr/share/update-notifier/notify-reboot-required
but I found at least one .postints
script which does also a touch /var/run/reboot-required
So looks like ultimately it’s the .postinst
files which are responsible creates the file /var/run/reboot-required
.
According to this post, the file /var/run/reboot-required.pkgs
lists the packages that requested the reboot. I could not verify that on my Debian Buster (yet).
RedHat-based systems
Apparently RedHat-based systems do not have the same mechanism. Looking at this post
This post gives an alternative: use needs-restarting
form the yum-utils
package. The man page needs-restarting
explains what the tool does:
needs-restarting is a program that reports a list of process ids that started running before they or some component that they use were updated.
So I can run this to see if a reboot is required
What is it good for?
This is obviously very helpful for your orchestration tool or your scripts to check whether a reboot is required.