Subject: Re: kill in bash script
To: joerch <helix@mayn.de>
From: Bill Schoolcraft <bill@linuxcare.com>
List: netbsd-help
Date: 11/13/2002 09:36:00
joerch wrote:
>
> On Wed, Nov 13, 2002 at 02:06:58PM +0000, Carlo Smith wrote:
> >
> > Thats the way to manualy find the pid and then kill it ... but how do I pick
> > out the pid in a script?
> >
>
> first go to your local bookstore and get one about shellscripting
> or about the bash.
>
> i am not sure if this will work on netbsd, but i think so:
>
> kill -HUP `ps ax |grep <name>|colrm 8`
>
I have to kill Netscape when it hangs alot so I created a script called
/bin/goodbye
#!/bin/sh
#
for i in `ps -auxw|grep netscape|grep -v grep|awk '{print $2}'`; do kill
-9 $i ; done
This works for me.
Or, you can replace the "netscape" with "$1" and then just run the
script from the command line using ANY service name like this:
$> goodbye netscape
The word netscape would be recognized as $1
#!/bin/sh
#
for i in `ps -auxw|grep "$1" |grep -v grep|awk '{print $2}'`; do kill -9
$i ; done
--
Bill Schoolcraft, Unix/Linux System Engineer
650 Townsend Street, San Francisco, CA 94103
"Unix/Linux, A Way Of Life."
http://www.linuxcare.com