Wednesday, April 30, 2008

One liner for killing processes

Here is a handy one-liner for killing a bunch of processes, postgres in this case.
It also uses the perlesque qualities of ruby. Googling "ruby oneliners" finds a bunch of other
one-liners. I tried sed at first but the regular expression support is different than perl.

ps auxww | grep postgres | ruby -pe 'gsub(/[ \t]+/, " ")' | cut -f 2 -d ' ' | xargs kill -9