kill a process

Garry T. Williams gtwilliams at gmail.com
Wed Aug 9 09:43:33 UTC 2006


On Wednesday 09 August 2006 01:54, Kaushal Shriyan wrote:
> I have to kill all processes which has owner as tester, If  there
> any specific command to that or i have to write script, if i read a
> PID into variable i cant kill the processes its not  getting killed
> below is the script.
> 
>  #!/bin/bash
> ps -ef |grep bdctest | grep -v root | awk '{print $2}'>out

So you now have a list of pids in the file called out.

> while read line
> do
> kill -9  $line ; echo $?
> done

This reads from stdin.  Didn't you want to read from the file out?

Maybe an easier way would be to:

    ps -ef|grep bdctest|grep -v root|awk '{print $2}'|xargs kill -9

-- 
Garry T. Williams --- +1 678 656-4579




More information about the fedora-list mailing list