Raw File
killemall2
#!/usr/bin/python
#
# kill 'em all !!
#    By William Stein (wstein@uw.edu, 2014)
# 

import os, sys

if len(sys.argv) == 1:
    print "Usage: %s [-9] word1 word2 "%sys.argv[0]
    print "Kills every process whose ps line contains all the given words."
    sys.exit(0)

this = sys.argv[0]
del sys.argv[0]
if sys.argv[0].startswith('-'):
    opt = sys.argv[0]
    del sys.argv[0]
else:
    opt = ''

words = sys.argv

for y in os.popen("ps ax").xreadlines():
    if this in y:
        continue
    match = True
    for w in words:
        if w not in y:
             match = False
             break 
    if match:
        print y
        s = "kill %s %s"%(opt,y.split()[0])
        print s
        os.system(s)

back to top