[SunHELP] Killing processes Part Deux
Thomas Cameron
sunhelp at sunhelp.org
Tue Feb 27 15:11:07 CST 2001
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 D. Cameron --
Red Hat Certified Engineer -- TurboLinux Certified Instructor
-- Certified NetWare Engineer --
Microsoft Certified Systems Engineer -- Microsoft Certified Trainer
-------------------------------------------------------------------
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