Results 1 to 6 of 6
Hi,
I have a script that calls other scripts/commands which may or may not spawn other process.
From my understanding, when I do a ps -ef, the highest numbered process ...
- 04-21-2011 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 10
Command to find parent and child process?
Hi,
I have a script that calls other scripts/commands which may or may not spawn other process.
From my understanding, when I do a ps -ef, the highest numbered process ID is supposed to be the parent ID of all the other related child processes, is this correct?
In most or all circumstances, I do a ps -ef | grep <processid> of my script and anything that spawns off that process IDs I assumed are the child processes of my script. If I want to terminate my script and all other child processes, then I kill the parent ID which is the highest numbered PID and this will subsequently kill all other child process IDs, is this correct?
Now, my question is whether there is any quick way of showing what are the child processes of a parent ID instead of what am currently doing now which is visually checking which one is the parent ID and "assuming" that the highest numbered PID is the parent ID of all the other processes.
Below is a sample output of running ps -ef | grep exp | grep -v grep. I assume from the output below that the parent process/ID is PID 11322, is that correct?
Any advice or suggestion will be much appreciated. Thanks in advance.
Code:oracle 11154 11153 0 21:20 ? 00:00:00 /bin/sh -c (. ~oracle/.profile; /bin/ksh /usr/local/oracle/scripts/expdp_o oracle 11155 11154 0 21:20 ? 00:00:00 /bin/sh -c (. ~oracle/.profile; /bin/ksh /usr/local/oracle/scripts/expdp_o oracle 11190 11155 0 21:20 ? 00:00:00 /bin/ksh /usr/local/oracle/scripts/expdp_schema.ksh dev01 oracle 11322 11190 0 21:20 ? 00:00:00 expdp
- 04-21-2011 #2
The pstree command lists processes as a branching tree. To start from a particular process, use its PID as an argument.
"I'm just a little old lady; don't try to dazzle me with jargon!"
- 04-22-2011 #3
I think that in your specific instance of the Oracle scripts firing up other scripts, killing the topmost PPID will work, but for reasons I've never really dug into, some child processes will reattach to PID 1 (init) instead of dying when the parent does. You don't want to kill that parent.
- 04-22-2011 #4
- 04-25-2011 #5Just Joined!
- Join Date
- Apr 2011
- Posts
- 1
In Redhat, at least, there is the --ppid option. So the command
ps --ppid <parent_process_id>
will list the child processes.
- 04-26-2011 #6Just Joined!
- Join Date
- Sep 2008
- Location
- Tampa Bay Area,FL
- Posts
- 9
Re: process children
If you are working in the Bourne shell, try:
ps --forest -ef
which will give you a better view of parent-child relationships among the processes.
This may not work on your implementation.
Hope this helps.


Reply With Quote
