Showing results for 
Search instead for 
Did you mean: 

percent cpu via ps auxw (berkely syntax)

Go to solution
Jim Booker

percent cpu via ps auxw (berkely syntax)

I am new to hpux. I am used to being able to use ps auxw (berkely syntax) primarily for
pulling off the %cpu column. Does anyone know how to get this info, and I don't want to use "top". I need to be able to gather this data from a script.

Thanks - Jim
Christopher McCray_1
Honored Contributor

Re: percent cpu via ps auxw (berkely syntax)

I think you'll like the ps -efl command, or just ps -l. Good luck.

It wasn't me!!!!
James R. Ferguson
Acclaimed Contributor

Re: percent cpu via ps auxw (berkely syntax)

Hi Jim:

Try using the UNIX95 option of the 'ps' command like this:

# UNIX95= ps -e -o pcpu -o ruser -o args|sort -nr|grep -v %CPU|head -10

This will give the top-10 highest %CPU entries. All processes are selected; the percentage CPU; login name and command line are reported, sorted by descending CPU utilization.

Note that there is a space (blank) after 'UNIX95' before the 'ps' command. Thus, the UNIX95 variable is used *only* for the 'ps' command and no other.

See the man pages for 'ps' for more information.



Re: percent cpu via ps auxw (berkely syntax)

When I run your command, I get the first 10 processes. Not the top 10 for cpu usage.
Bill Hassell
Honored Contributor

Re: percent cpu via ps auxw (berkely syntax)

The percentage CPU usage is only measured during the most recen scheduling interval and is not a useful measurement of the cumulative percentage of CPU across all processes. ps has no history and is a simple snapshot once through the process tables.

A better choice is to sort the process by accumulated CPU time as in:

UNIX95= ps -eo time,ruser,args | sort | more

To better see the relationship of all processes to each other, you can use Glance or top (Glance is much more useful). You can sort the interesting processes by CPU usage.

Bill Hassell, sysadmin