1752294 Members
4695 Online
108786 Solutions
New Discussion юеВ

Re: ps cmmand syntax

 
chuikingman
New Member

ps cmmand syntax

I use hp unix .
I want to get vsz of the process .
What is the syntax ...

/run>ps -help
ps: illegal option -- h
ps: option requires an argument -- p
usage: ps [-edaxzflP] [-u ulist] [-g glist] [-p plist] [-t tlist] [-R prmgroup] [-Z psetidlist]

7 REPLIES 7
Dennis Handly
Acclaimed Contributor

Re: ps cmmand syntax

>ps -help

The correct command for help is: man ps
http://h20000.www2.hp.com/bc/docs/support/SupportManual/c02264235/c02264235.pdf

To get vsz you need to use -o:
UNIX95=EXTENDED_PS ps -p PID -opid,vsz,comm
chuikingman
New Member

Re: ps cmmand syntax

the option "-o" is not supported.
Please advice other ...

/run>ps -eo vsz
ps: illegal option -- o
usage: ps [-edaxzflP] [-u ulist] [-g glist] [-p plist] [-t tlist] [-R prmgroup] [-Z psetidlist]
/run>uname -a
HP-UX XXXXXX B.11.11 U 9000/800 2311410363 unlimited-user license
Ralph Grothe
Honored Contributor

Re: ps cmmand syntax

You need to read Dennis' reply more carefully, and set the environment variable UNIX95.
If this variable is set a bunch of system commands behave differently (aka XPG4 behavior).
As for the ps command itself, when run in that environment it will recognise the -o (and further) options (read man ps).
Because not only the ps command will be affected by a set UNIX95 env var it usually is wise to set UNIX95 only temporarily instead for the whole shell session. That's why Dennis prepended the UNIX95 string to the actual ps command (another way would have been to use the env command, but this would have required a little more typing).
Madness, thy name is system administration
chuikingman
New Member

Re: ps cmmand syntax

Ok it work and thankyou

/run>env | grep U
COLUMNS=80
UNIX95=EXTENDED_PS
/gxs20/run>

/run>ps -p 5306 -opid,comm,stime,time,pcpu,state,vsz
PID COMMAND STIME TIME %CPU S VSZ
5306 java Jan 31 02:23:02 2.79 R 51260
Dennis Handly
Acclaimed Contributor

Re: ps cmmand syntax

>UNIX95=EXTENDED_PS

As mentioned by Ralph, this is probably NOT what you want to do. This causes all sorts of changes in commands that may break your scripts/expectations.

Instead you should do:
UNIX95=EXTENDED_PS ps -p 5306 -opid,comm,stime,time,pcpu,state,vsz

By setting UNIX95, you have also turned on FIDDLE_WITH_FIND_TIMES:
http://h30499.www3.hp.com/t5/System-Administration/need-to-remove-files-older-that-1-day/m-p/4341484#M343630

Bill Hassell
Honored Contributor

Re: ps cmmand syntax

And to expand on Dennis's answer, do not set the UNIX95 variable in your shell - it will affect too many unrelated processes. You must put the assignment on the same line as ps. That way, the variable only exists during the ps command and disappears when ps is finished. The UNIX95=EXTENDED_PS assignment can be shortened to UNIX95=1 or even UNIX95=. The value is unimportant, just the variable name needs to be defined. So this works too:

UNIX95= ps -p 5306 -opid,comm,stime,time,pcpu,state,vsz



Bill Hassell, sysadmin
Ralph Grothe
Honored Contributor

Re: ps cmmand syntax

Of course, it is correct what Bill added,
and I often myself prefer for the sake of laziness the non-assigning command-scope definition "UNIX= ps ...".
(Is this correct spelling? I'm never sure about hyphenation in English. Sure, in German we make ample use of hyphens and noun concatenations to form impressive word monsters; e.g. http://www.crossmyt.com/hc/linghebr/awfgrmlg.html)
On the other hand, in a script I would rather prefer Dennis' allusive, intuitive and self-explanatory assignment of "UNIX95=EXTENDED_PS ps ...".
Madness, thy name is system administration