Operating System - HP-UX
1753317 Members
5166 Online
108792 Solutions
New Discussion юеВ

Re: How to know which process is taking lot of CPU usage?

 
Deepu Chakravarty
Regular Advisor

How to know which process is taking lot of CPU usage?

I am running rp7420 server with HPUX 11.11. Through 'top' command I can see the processes. But I need to know only processes CPU wise. How 'ps' command can be constructed so that I can know top 10 processes which are taking lot of CPU usage?
Thanks in advance.
5 REPLIES 5
James R. Ferguson
Acclaimed Contributor

Re: How to know which process is taking lot of CPU usage?

Hi:

Define "...a lot of CPU usage". Does this mean as a cumulative amount since the process instantiation? Does this mean over n-interval?

How about this:

# UNIX95= ps -e -o pid= -o time= -o pcpu= -o comm=|sort -rk2,2|head -10

Note the whitespace after the equal sign in 'UNIX95'. This keeps this option set only for the duration of the command line.

The headings are suppressed for the output and only the top ten largest CPU processes are listed.

See the 'ps' manpages for more information.

Regards!

...JRF...
Hari PN
Occasional Advisor

Re: How to know which process is taking lot of CPU usage?

please try the following command.

# export UNIX95=
# ps -eo "user,pid,pcpu,args" | sort -rnk3 | more
James R. Ferguson
Acclaimed Contributor

Re: How to know which process is taking lot of CPU usage?

Hi (again):

Do NOT set UNIX95 and export it to your environment! This can alter the behavior of several commands in ways that you might not be aware.

This is the reason I said to only set it for the duration of the command that needs it, as:

# UNIX95= ps ...

Regards!

...JRF...
Paul Sperry
Honored Contributor

Re: How to know which process is taking lot of CPU usage?

top is easy enough to use.

top - display and update information about the top processes on the
system.

/usr/bin/top
Paul Sperry
Honored Contributor

Re: How to know which process is taking lot of CPU usage?

never mind didn't read full post