Posted By

noah on 09/28/10


Tagged

grep perl ps kill processes cut tools sysadmin one-liners Hudson zombie sysops ops


Versions (?)

kill zombie processes


 / Published in: Bash
 

Thanks to Kastner for these snippets.

  1. # for one proc
  2.  
  3. ps ax | grep 'java -jar start.jar' | grep -v 'grep' | cut -f 2 -d " " | xargs kill -9
  4.  
  5.  
  6. # when you don't want the output, and don't want to return nonzero
  7. # in the event the process isn't running
  8. # useful, eg when running inside of a Hudson build step
  9.  
  10. ps ax | grep 'java -jar start.jar' | grep -v 'grep' | cut -f 1 -d " " | perl -ne 'qx{kill -9 $_} if $_'
  11.  
  12.  
  13.  
  14. # for many procs
  15.  
  16. for i in Xvfb selenium sprouter pgproxy mockservers; do ps ax | grep $i | grep -v grep | cut -f 1 -d " " | xargs kill -9 ; done

Report this snippet  

You need to login to post a comment.