Killing process in Linux with all child processes. What is the best way?

  • From: J.Velikanovs@xxxxxxxx
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Fri, 21 Jan 2005 22:26:00 +0200

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.

# 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,
+371 9268222 (+2 GMT)
Thank you for teaching me.


Other related posts: