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

Walter Krumshyn wallyk at nortelnetworks.com
Thu Jan 20 11:59:19 CST 2000


You could do something like the following.  Create a file with the
following contents (with execute permissions) and run it with the
program you want to kill as an argument.  

E.g. KillProcess <process_name>


#!/bin/sh

# Kill all processes which have the argument as part of the process
name.
# Remove the process ID of the grep process and this program.

for i in `ps -ef | grep $1 | egrep -v "grep|$0" | awk '{print $2}'`
do
  echo Killing Process $i
  kill $i
done

Regards,

Walter Krumshyn


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






More information about the SunHELP mailing list