David StevensonDavid Stevenson
Standup for 2/5/2009: Looking for processes with pgrep & pkill
edit Posted by David Stevenson on Thursday February 05, 2009 at 05:28PM

Interesting Things

  • pgrep is a sweet tool for finding processes. You can find all your mongrels, for example, without having the problems of running ps aux | grep ruby. It's in the proctools package on most linux/unix operating systems. For example, on osx use sudo port install proctools
  • kill -482 kills all processes in the group 482. This is great for killing all the children of a daemon like mysql or backgroundrb. ps shows the process group id next to the process id.
  • monit doesn't have great support for figuring out what happens when a start/stop command runs. It can fail silently, for example. One (bad) way of debugging this is to add echo to dump debugging info to a temporary file before and after these commands. Rumor has it that god doesn't have these problems...
  • we've heard a rumor that Marshal.dump(object) uses a temporary file on disk! This would be slower than it needed to be. Perhaps this is to deal with dumping objects to large to fit in RAM?

Comments

  1. Brian Jenkins Brian Jenkins on February 06, 2009 at 01:55AM

    (on linux) you can get the pgroup of a process with pid 555 like this:

      ps h -o pgrp 555
    

    (-o selects the columns to display, h suppresses column headers.)

  2. coderrr coderrr on February 08, 2009 at 05:07PM

    pgrep/pkill -f is awesome for substring matching