Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Killing process in Linux with all child processes. What is the best way?
Thank you all who pointed me on pkill/pgrep.
One little inconvenience, which these can’t handle: it is subcalls.
Lets say my script calling other script and so on.
For example I have process hierarchy like below
|-sshd,754)
|-sshd,25317) `-bash,25547) `-su,25597) - cacti `-bash,25598) |-pstree,28688) -ap `-sh,28946) ./cron_test.sh `-sleep,27900) 20
I would like to kill all those processes. If I run pkill –P 754, just two processes going to be killed (754, 25317).
Is there better chance to kill them, except I have posted?
Jurijs
+371 9268222 (+2 GMT)
J.Velikanovs_at_alise.lv
Sent by: oracle-l-bounce_at_freelists.org
2005.01.21 22:34
Please respond to J.Velikanovs
To: oracle-l_at_freelists.org cc: Subject: Killing process in Linux with all child processes.What is the best way?
Hi ALL,
Looks like off topic, but it can be useful for Oracle administration
purposes on Linux (Unix) platform.
I have need to kill one of my shell scripts in case of timeout is off. Not just single process but all that is relative to it.
After searching thought net I have wrote my routine. Looks like there is place for improvement. Can somebody recommend one, or somebody has more elegant way how to achieve the goal.
#!/bin/bash
# there $1 is pid of the process
v_pforkill=`pstree -p $1 |
awk -F"-" '{NF>0;for (i=1;i<=NF;i++) print $i}' |
sort -u |
awk -F"(" '{print $2}' |
awk -F")" '{print $1}' |
sort -u |
awk '{ORS=" "; print $1 }'`
kill -9 $v_pforkill
With all my respects,
Jurijs
+371 9268222 (+2 GMT)
-- http://www.freelists.org/webpage/oracle-l -- http://www.freelists.org/webpage/oracle-lReceived on Fri Jan 21 2005 - 17:53:31 CST
![]() |
![]() |