I need to be able to kill a parent process based on the child process name.
I can use "ps aux | grep xxx" to find the parent parent process ID - but how
do I get that number out of that line? I need to pipe that number to kill,
so that the parent is dead and all it's children die. I tried to pipe it to
cut, but I couldn't get it work every time. Or maybe there is a command
that reports the parent of a process? That would be the handiest.
Some more background info:
Thanks to your guys' help, I have a simple script (included below), that
just runs a few programs in a loop for me. But the parent of the process
is -bash. The problem is when I want to stop the mirror program. Of course
I can't just "killall mirror" because the shell will just start another one
(because of the loop). Now, because the parent is bash, then I would have
to kill all bash processes (assuming I don't know which bash started my
"mirror"s) to get the child processes (mirror) to stop.
Is there a command that will return the name of the parent of a given
process? Then I could pipe that to killall.
Here is the contents of the file newmirrormandrake.sh
----------------------------
M=/home/danb/mirror/mirror.mandrake
while true
do
mirror -pMandrake $M
mirror -papps $M
mirror -pdoc $M
mirror -pdosutils $M
mirror -pimages $M
mirror -pmisc $M
done
----------------------------
TIA.
Dan Browning
Network Administrator
Cyclone Computer Systems
killing a parent based on the child process name
Dan Browning (Network Admin) Fri, 26 Feb 1999 20:14:27 -0500
- Re: killing a parent based on the child proce... Dan Browning (Network Admin)
- Re: killing a parent based on the child ... Deirdre Saoirse
- Re: killing a parent based on the child ... lawson_whitney
