Operating System - HP-UX
1833770 Members
2463 Online
110063 Solutions
New Discussion

Parent / Child Process id.

 
SOLVED
Go to solution
Pheroz Tengra
Advisor

Parent / Child Process id.

Does any one have a handy script to know the process id of certain background tasks and all of their associated child processes in KSH.

Thanks in advance.
7 REPLIES 7
Krishna Prasad
Trusted Contributor

Re: Parent / Child Process id.

ps -ef | grep "name of process" | awk ' { printf "Process id = %s Parent Process id = %s\n", $2, $3 }'
Positive Results requires Positive Thinking
Mark Greene_1
Honored Contributor
Solution

Re: Parent / Child Process id.

Sam will show you this under Process Management, Process Control.

If you want something you can call from a script, HP used to have a script called ptree. I cannot find it on my 11.0 install, but have a copy on another system, which I've attached.

HTH
--
mark
the future will be a lot like now, only later
Steven Gillard_2
Honored Contributor

Re: Parent / Child Process id.

You can use the -H option to ps, which requires the UNIX95 env var to be set. The following will give you the whole process tree, then you can look for your process under that.

# UNIX95= ps -eH

Regards,
Steve
Uday_S_Ankolekar
Honored Contributor

Re: Parent / Child Process id.

Hi,

use of Glance /gpm is certianly help.

-USA
Good Luck..
Paula J Frazer-Campbell
Honored Contributor

Re: Parent / Child Process id.

Hi

ps -ef | grep -v grep | grep | awk '{print $2,$3}'

From my machine:-

root@N-0/etc>ps -ef | grep -v grep | grep inetd | awk '{print $2,$3}'
17315 1
the 17315 is child and 1 is parent

Paula

If you can spell SysAdmin then you is one - anon
Pheroz Tengra
Advisor

Re: Parent / Child Process id.

Thanks for everyone's response. The awk/grep method is not adaquete, as that is already part of the ps header. However Mark Green's ptree script was what I was looking for.

Thanks Mark.
SSP_1
Regular Advisor

Re: Parent / Child Process id.

HI Uday Ankolekar,

Aaapla email id kaay aahe?
Otherwise please mail me on "sspatkar@hotmail.com".


Ever Friendly,
Shripad
Obstacles exist to challenge you to keep going. Not to quit.