[Sunhelp] Problem on creating a script to kill processes.

John Kennedy jkennedy at orent.com
Thu Jan 20 11:31:45 CST 2000


Miguel Demaerel wrote:
> 
> Hoi All
> 
> I'm a newbie on this platform.
> 
> I wont to create a script that kill several processes.
> 
> ps -ef | grep "name" |awk '{print $2}
> Now I have a list of PID, but how can I kill these processes?
> 
> kill ???
> 
> Are there any good site or books on writing scripts?
> 
> Thanks
> 
> Greetings Miguel
> 
>                    ////
>                   (o o)
> ==============oOO==(_)==OOo==============
>              Miguel DEMAEREL
>         Sema Group Managed Services
>        Raketstraat 98 - 1130 Brussel
>                  Belgium
>        Tel: +32 (0)2 724 93 17
>        Fax: +32 (0)2 724 92 92
>  EMail: Miguel.Demaerel at SGMS.SEMA.BE
> =========================================
> 
> _______________________________________________
> SunHELP maillist  -  SunHELP at sunhelp.org
> http://www.sunhelp.org/mailman/listinfo/sunhelp
Miguel,
I use the following VERY basic script to kill multiple processes of the
same name.  I call the script pkill (After the Solaris 7 command) and
use it on my RedHat Linux box with the following command:
pkill 'process name' (i.e. pkill soffice)
There are several scripting books available.  Anything by O'Reilly
publishing is well worth the money.
John

---------------------------Cut here
----------------------------------------------
#!/bin/sh
echo ""
echo ""
echo "Checking to see if process is running..."
echo ""
echo ""
ps -ef | grep $1 | grep -v grep
echo ""
echo ""
echo "Killing processes..."
kill -9 `ps -ef | grep $1 | grep -v grep | awk '{print $2}'`
echo ""
echo ""
echo "Checking to make sure process is dead..."
echo ""
echo ""
ps -ef | grep $1 | grep -v grep 

--------------------------Cut
here-----------------------------------------------
-- 
Your anti-Microsoft signatures for Thursday are...

"One World, one Web, one Program" - Microsoft promotional ad
"Ein Volk, ein Reich, ein Fuhrer" - Adolf Hitler

Name one nice thing about Windows?... 
It doesn't just crash, it displays a dialog box and lets you press 'OK'
first.






More information about the SunHELP mailing list