Get CPU,Memory utilization by process id

Hi ,
We need to get the CPU% and Memory utilization of process by process id.
Is there any way to do get them ?

I tried few commands like top -p <PID> ,
but am getting error "Quitting top: pset <PID> doesn't exist"
also i tried with ps -eo option but am getting error "ps: illegal option -- o"

when i executed uname -a command i got following as output
"HP-UX servername B.11.23 U ia64 0318662421 unlimited-user license"

we are using hp-ux..Does the above commands doesnt work here?
What are the commands in hp-ux to get the CPU and memory utilization of process

Thanks,
Suresh

Using the "UNIX95= " prefix (the space after the equals sign is important) you can use the alternative "ps" syntax as described in "man ps". This enables you to choose whatever fields you like in whatever order:

Some examples:

For a single process (in this case PID 4161)
UNIX95= ps -p 4161 -o pid,sz,pcpu,ruser,args

For all processes:
UNIX95= ps -e -o pid,sz,pcpu,ruser,args

Top 5 highest cpu user
UNIX95= ps -e -o pcpu,pid | sort -n -r |grep -v "%CPU"|head -5

Hi methyl,
We are using HP-UX OS.when we executed uname -a command , we got following output
"HP-UX servername B.11.23 U ia64 0318662421 unlimited-user license"

When i tried the options mentioned by you , am getting following error
"ps: illegal option -- 0"

Please let me know how to check this

Thanks,
Suresh

There is no character zero in any line I posted. There is a lower case "o".

If it isn't just a typo, please post the exact line which fails (in code tags). The "UNIX95= " prefix is part of the line you type.

On your other problem, there is no "-p" switch to "top". See "man top".

Hi Suresh,
If you know the process id you can use the following command for getting the process by process id

ps -ef |grep <process id>

@vishal.bordia
Please read the thread before posting.
You have managed to give a wrong answer to the wrong question.
If you wanted detail for a single process it would be:

ps -fp<process id>

The grep approach gives false hits.
Also the output from the default HP-UX "ps" does not contain the fields which the O/P wanted.

As you mention in another post HP "glance" program (pay software) gives full detail but of course the output is not suitable for processing in Shell.
You can buy full works server monitoring packages from HP.