---------PARENT SCRIPT (have to run in background sh parent.sh &)------------------
sh child1.sh
--------- child script -----------------
ps -eaf | tail
for i in `ps -ef | grep parent.sh | grep -v grep | awk '{print $2}'`
do
echo "parent.sh pid = $i"
ps -eaf | tail
done
for j in `ps -ef | grep child | grep child1.sh | aek '{print $2}'`
do
echo "child1.sh pid = $j"
done
pid = $`ps -o user, pid , ppid -ax | grep parent |awk '{print $2}'`
for k in $`ps - o user , pid , ppid -ax`
do
if [$pid = $i,$j]
echo "parent or child process"
else
kill -9 $pid
#fi
what i am trying is running is -
running a child script in parent script
and in child script i want to collect all the process pid's that are initiated from parent.sh
and kill them all except for parent process and child process..
after that i am trying to display on terminal that when i will kill the parent process , child process will be having init as it parent