AlwaysALearner AlwaysALearner - 1 year ago 85
Bash Question

How to get child process from parent process

Is it possible to get the child process id from parent process id in shell script?

I have a file to execute using shell script, which leads to a new process process1 (parent process). This process1 has forked another process process2(child process). Using script, I'm able to get the pid of process1 using the command:

cat /path/of/file/to/be/executed

but i'm unable to fetch the pid of the child process.

Answer Source

Just use :

pgrep -P $your_process1_pid
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download