Hi all,
I want to write a small script to kill processes matching a given input string. I use the code below but of course this also shows up on the ps list.
I have to put all the grep's in to mask out this process, is there some way of doing this without the current process lighting up?
I want to write a small script to kill processes matching a given input string. I use the code below but of course this also shows up on the ps list.
Code:
#!/bin/csh -f
set myname=`whoami`
if ($#argv == 1 ) then
if (`/bin/uname` == "Linux") then
set myid = `id -u $myname`
kill -9 `ps -u $myname | grep -i $1 | grep -v grep | grep -v ps | grep -v tcsh | awk '{print $1}'`
endif
endif
I have to put all the grep's in to mask out this process, is there some way of doing this without the current process lighting up?