[SunHELP] Killing processes Part Deux

David Bishop sunhelp at sunhelp.org
Tue Feb 27 15:28:52 CST 2001


And this doesn't work at all, keeps complaining that -f is an illegal option.
 I normally use ps ax, not ps -ef.  I'm fairly certain that the "cut" part of
my program is working, in that it successfully returns me the list of pids. 
If you notice my second line in the first email was a "echo $a" to double
check that.  Any other ideas?


On Tue, 27 Feb 2001 14:36:07 -0600, Thomas Cameron said:

> Cut is a pretty stupid program.  use awk instead:
>  
>  #!/bin/sh
>  for process in `ps -ef | grep $1 | awk '{ print $2 }'`; do
>    kill "$process"
>  done
>  
>  Regards,
>  Thomas
>  
>  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
>  _______________________________________________
>  SunHELP maillist  -  SunHELP at sunhelp.org
>  http://www.sunhelp.org/mailman/listinfo/sunhelp
>  
>  




More information about the SunHELP mailing list