[SunHELP] Killing processes Part Deux

Vinay Bharel sunhelp at sunhelp.org
Tue Feb 27 14:38:35 CST 2001


You are making it too complicated. If you want to kill all processes named
foo, just do...

ps -e | grep foo | grep -v grep | awk '{print $1}' | xargs kill -9

- Vinay Bharel <vinay at bharel.com>

On 27 Feb 2001, David Bishop wrote:

> So, the pkill command works *wonderfully* ... on my Solaris 7 boxen. 
> However, I have the same problem on Solaris 2.6, and it's giving me fits.  I
> sat down and came up with a wonderfully simple way to do this in bourne
> shell, but for some reason, it doesn't consistently work.  Any ideas?
> 
> 
> bash-2.04$ a=`ps ax | grep datd | grep -v grep | cut -f3 -d" "`
> bash-2.04$ echo $a
> 7713 7754 7755 7759 7761 7762 9057 9058 9059 9060 9061
> bash-2.04$ for i in $a
> > do `kill $i`
> > done
> bash-2.04$ ps ax | grep datd
>   7713 ?	S  0:00 /usr/usr3/bin/datd
>   7754 ?	S  0:00 /usr/usr3/bin/datd
>   7755 ?	S  0:00 /usr/usr3/bin/datd
>   7759 ?	S  0:00 /usr/usr3/bin/datd
>   7761 ?	S  0:00 /usr/usr3/bin/datd
>   7762 ?	S  0:00 /usr/usr3/bin/datd
>   2769 pts/0	R  0:00 grep datd
> bash-2.04$ a=`ps ax | grep datd | grep -v grep | cut -f3 -d" "`
> bash-2.04$ for i in $a; do `kill $i`; done
> bash-2.04$ ps ax | grep datd
> 
> So, there was two "sections" of datd running, first with pid's in the 77xx
> range, and then in the 90xx range.  The first do loop only killed the 90xx
> section, but doing the exact same thing resulted in the 77xx section dieing
> the second time.  I'll admit, I'm confused.  And this *is* replicable
> behavior, it happens every time.  Is there something obvious that I'm
> missing, or is this a known bug?
> 
> TIA and HAND,
> 
> D.A.Bishop
> _______________________________________________
> SunHELP maillist  -  SunHELP at sunhelp.org
> http://www.sunhelp.org/mailman/listinfo/sunhelp
> 




More information about the SunHELP mailing list