Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ps option to list all child processes...

Status
Not open for further replies.

schocku

Programmer
Nov 20, 2001
23
US
I have a main.ksh that executes a perl script and which in turn spawns child ksh processes and awk scripts. I have main.ksh in crontab to run every 10 mins.

Is there a way to make sure that neither an earlier version of main.ksh or ANY OF ITS CHILD PROCESSES are running when crontab starts main.ksh.

Basically is there a ps option that lists out all the child processes of a parent process ?

Thanks for your help.
 
Try something like this:
Code:
ps -fe | awk '
function child(id  ,i){
 print line[id]
 for(i in ppid) if(ppid[i]==id) child(i)
}
{ppid[$2]=$3;line[$2]=$0}
/main.ksh/{if($2!='$$') pid=$2}
END{if(pid) child(pid)}
'

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top