General
cancel
Showing results for 
Search instead for 
Did you mean: 

Isolate top process consuming cpu and memory

Alok_Behria
Advisor

Isolate top process consuming cpu and memory

 

Hi All,

 

cpmtest> uname -a
HP-UX oradev1 B.11.23 U ia64 0074225043

 

I am trying to isolcate top process in terms of memory and cpu. I am using following command to get those details.

it seems to me, on HPUX, it may not be the command to achieve the desired result.

 

cpmtest> ps -e -o pcpu,pid,user,tty,args | sort -n -k 1 -r | head
ps: illegal option -- o
usage: ps [-edaxzflP] [-u ulist] [-g glist] [-p plist] [-t tlist] [-R prmgroup] [-Z psetidlist]
Usage: sort [-AbcdfiMmnru] [-T Directory] [-tCharacter] [-y kilobytes] [-o File]
           [-k Keydefinition].. [[+Position1][-Position2]].. [-z recsz] [File]..

cpmtest> ps -e -o pmem,pid,user,tty,args | sort -n -k 1 -r | head
ps: illegal option -- o
usage: ps [-edaxzflP] [-u ulist] [-g glist] [-p plist] [-t tlist] [-R prmgroup] [-Z psetidlist]
Usage: sort [-AbcdfiMmnru] [-T Directory] [-tCharacter] [-y kilobytes] [-o File]
           [-k Keydefinition].. [[+Position1][-Position2]].. [-z recsz] [File]..

 

 

 

 

3 REPLIES
Patrick Wallek
Honored Contributor

Re: Isolate top process consuming cpu and memory

The following should do what you want:

 

UNIX95=1  ps -eo pcpu,pid,user,tty,args | sort -rnk 1,1 | head

 

The key changes are:

 

1) Adding the UNIX95=1 to enable the XPG4 options to the 'ps' command.

 

2) Redoing the sort command.  The order you had the arguments in didn't work.  Having the '-r' last is not valid syntax.

 

 

Duncan Edmonstone
Honored Contributor

Re: Isolate top process consuming cpu and memory

You coming from Solaris? The ps command works slightly different on HP-UX, and you need to be careful with your sort syntax as well...

 

By default, HP-UX uses its own ps implementation, to get it to behave like the UNIX 95 standard you need to set the UNIX95 environment variable, but typically you don't want it set by default, so if you want to use any of the command arguments/options listed as "UNIX Standard Only" on the ps man page, you do something like this:

 

UNIX95= ps -eo pcpu ...

 

So your first command line becomes:

 

UNIX95= ps -e -o pmem,pid,user,tty,args | sort -nr -k 1  | head

 

(note I fixed your sort syntax as well)

 

For your second command line - there is no equivalent of pmem, so the closest you can probably get is vsz - so try:

 

UNIX95= ps -e -o vsz,pid,user,tty,args | sort -nr -k 1  | head


HTH

Duncan
Dennis Handly
Acclaimed Contributor

Re: Isolate top process consuming cpu and memory