#!/usr/local/bin/perl $name = $ARGV[0]; @proc = split(/\n/, `ps -e -o pid,fname=1234567890`); foreach $prcline (@proc) { $prcline =~ /\s*(\S+)\s+(\S+)/; # split into the 2 fields of 'ps -e -o pid,fname' line $pid = $1; # process id $prc = $2; # process name if ($prc eq $name) { print "Found process $prc of pid $pid\n"; kill 15, $pid; sleep 2; # If reason doesn't work, use force kill 9, $pid; print"killed $pid\n"; $flag = 1; } } die "Killed no processes" unless ($flag);
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 1472 | Yariv Sheizaf | scripts dir |