Determine when reboot required after patching from the command line?

Posted on

Problem :

After ssh‘ing into a box and using yum or apt-get to patch, I would like to determine when a reboot is required. It would be incredibly helpful to know so we can schedule a reboot in a maintenance window.

Surprisingly, I did not find much reading on it. About the closest thing I found on a web search was How do I know if a reboot is required after patching? from Verizon, which effectively stated Linux does not usually need it because programs restart themselves (I suppose it was written for the average consumer).

I know Linux GUI’s offer it because, for example, the power button icon will turn red on Ubuntu/Unity. And I get prompted like below when logging in with a windows manager.

enter image description here

I regularly work with Debian, Ubuntu, Fedora, CentOS and Red Hat, so its the reason I listed yum and apt-get.

How do I determine when a reboot is required after patching?

Thanks in advance.

Solution :

In Debian-based OSes, the package manager will create a file, /var/run/reboot-required, if a patch requires a reboot. This file is deleted when the machine is restarted. See this AskUbuntu post for more information about how to determine which package required a reboot.

To get the same functionality in yum, it appears that you need to install a third-party plugin.

Leave a Reply

Your email address will not be published. Required fields are marked *