what needs to be restarted

November 3, 2009

A common problem I’ve encountered for years is how to know what daemons need to be restarted in order to take advantage of some update or to be sure that they are running the secure version of the libs you just updated. I was thinking about this yesterday and realized I had all the tools necessary to find this out.

I came up with this simple script: needs_to_be_restarted.py

Now, it might be a bit overly simple and that is why I’m asking here. All it does is go through each of the processes in /proc/###### open the smaps file and look for files. For any of the files in there, it checks if a pkg owns them. If it does it checks what the installtime is on that package. If the installtime of the package is newer than when the process was started then it reports that pid (and the cmdline).

Now, this won’t work in every case, and I may have it report if the files have been removed but it seems to work pretty well.

If there are more foolproof ways to know or additional checks I should add, let me know.

If this looks good I’ll probably add some options and add it to yum-utils.


6 Responses to “what needs to be restarted”

  1. Brett Says:

    This is an excellent thing to have!

    This should also become a Func module, for larger scale use cases.

  2. comodet Says:

    This is really seems usefull..!

  3. Mark T. Kennedy Says:

    seth, i’ve been using this script since i first stumbled over it. it seemed to give better answers than needs-restarting from yum-utils (although for all i know you wrote that one too :-). recently, on two FC17 systems (kept up-to-date against updates-testing), it started listing a number of false positives. when i poked around, i discovered that a bunch of the /proc/$PID entries had ST_CTIMES that were from before the last boot? is this some kind of systemd-related change?

    • skvidal Says:

      Were those systems, perhaps, VMs? I don’t know of any other way that could happen.

      • Mark T. Kennedy Says:

        one is (under vmware), the other isn’t (real hardware). unfortunately, the one on real hardware has died the big flaming death 🙂 and is waiting to have its OS re-installed (probably FC18 this time). why would you suspect a VM?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: