1834621 Members
2435 Online
110069 Solutions
New Discussion

ptree

 
SOLVED
Go to solution
michael Fischer_1
Occasional Contributor

ptree

Hello everybody,

I'm looking for a command like "ptree" (SUN Solaris) in HP-UX 11.0, that gives me a process-tree of all processes (parent - child). I want to integrate it into a shell-skript, so I can't use sam. Is there everything else like ps -ef | grep -v grep | grep | awk '{print $2,$3}' ?

Any Idea?

Thanks!
8 REPLIES 8
James R. Ferguson
Acclaimed Contributor

Re: ptree

Hi:

You could try:

# UNIX95= ps -eH

Note the blank after the UNIX95 variable and the absence of any semicolon before the 'ps' command. This sets the XPG4 behavior for the duration of the command line only.

Regards!

...JRF...
harry d brown jr
Honored Contributor

Re: ptree

Maybe something like xps:

http://www.netwinder.org/~rocky/xps-home/xps.html


live free or die
harry
Live Free or Die
Mark Greene_1
Honored Contributor
Solution

Re: ptree

attached is the hp version of ptree.sh

--
mark
the future will be a lot like now, only later
harry d brown jr
Honored Contributor

Re: ptree

Mischa,

forget about xps, it doesn't run on hpux - those dogs!


live free or die
harry
Live Free or Die
T. M. Louah
Esteemed Contributor

Re: ptree

To add to above here's UNIX95 by some examples:
To sort all the proceses by memory size:

# UNIX95= ps -eo vsz,ruser,args | sort -rn | more

To find all processes that have a specific basename:

# UNIX95= ps -fC process_name

No grep needed, and most important, it returns ONLY the deamon (or process) you are after. Check out the difference between:
ps -ef | grep sh
UNIX95= ps -fC sh

The second form (which activates the -C option in XPG4 mode) is really inetresting.

Another feature is the ability to create a customized output format, if you don't need start-time (which varies in format), you can eliminate it. Consider this form:
UNIX95= ps -C sh -o ruser,pid,args

g'd luck
t++
Little learning is dangerous!
Joseph C. Denman
Honored Contributor

Re: ptree

ptree???

Isn't that one of the char in "The Land Before Time"?

Sorry, my daughter had me watch it with her the other night.


The above UNIX95 should give you what you want.


...jcd...
If I had only read the instructions first??
michael Fischer_1
Occasional Contributor

Re: ptree

Well, thank you everyone for your help and comments! The "UNIX95" command with all its options is what I was looking for...

Regards!

Mischa
Peter Kloetgen
Esteemed Contributor

Re: ptree

Hi Mischa,

the UNIX95- Variable should be set only when needed, because there are a lot of other shell scripts, used by your system, which have problems if this variable is set. ( Some of them even have a command line: unset UNIX95 )
Another remark: You can use the option -H for the ps- command no matter which value was assigned to the variable.

Allways stay on the bright side of life!

Peter
I'm learning here as well as helping