cancel
Showing results for 
Search instead for 
Did you mean: 

find out the high process

SOLVED
Go to solution
gany59
Regular Advisor

find out the high process

how to find which process is occupying more CPU usage and more memory usage if we use top or ps -ef command, is there any possibilities to find out.
8 REPLIES
Dennis Handly
Acclaimed Contributor

Re: find out the high process

top list the top CPU users. If you put the info into a file with "-f file", you can sort on the SIZE field.
James R. Ferguson
Acclaimed Contributor

Re: find out the high process

Hi:

Use 'ps' and sort:

# UNIX95= ps -e -ovsz= -opid= -ocomm=|sort -knr1,1

There is nothing but whitespace after the 'UNIX95=' and before the 'ps'. This keeps UNIX95 behavior set only for the commandline. To do otherwise may lead to different behavior than you want. The '-o' option selects the fields to display and the trailing '=' suppresses the field headers. The sort orders the process list in descending virtual memory size.

For the CPU usage, I assume that you mean the cumulative execution time as returned by 'ps':

# UNIX95= ps -e -otime= -opid= -ocomm= | sort -kr1,1

Regards!

...JRF...
gany59
Regular Advisor

Re: find out the high process

Hi JRF,

I used the above commands, but i am not ablt differentiate between the CPU usage and memory usage;

below is the pasted O/P :
UNIX95= ps -e -otime= -opid= -ocomm= | sort -kr1,1
6-11:57:33 263 syncer
302-01:32:36 457 sar
276-15:49:27 27578 userProfileLogin
265-11:53:37 18228 sar
2-19:27:01 903 awk
2-10:17:33 6892 focusVM
2-04:40:16 535 snmpdm
2-02:55:51 3 statdaemon
2-00:42:15 77 netisr
14-15:15:32 427 ypserv
12-14:27:33 76 netisr
1-17:11:17 7 ttisr

====================================================================

UNIX95= ps -e -ovsz= -opid= -ocomm=|sort -knr1,1
11896 5982 queryEvents
6508 606 rpcd
4256 8573 confOmReport
4244 299 swagentd
4240 26961 perl
2880 27578 userProfileLogin
2400 6892 focusVM
1924 26979 top
1916 26949 top

Pls help me out on this..
James R. Ferguson
Acclaimed Contributor
Solution

Re: find out the high process

Hi (again):

> I used the above commands, but i am not ablt differentiate between the CPU usage and memory usage;

I don't understand what you are missing. If you drop the '-o' parts of the 'ps' arguments you have 'time, 'pid' and 'comm' for the CPU utilization run and 'vsz', 'pid' and 'comm' for the memory report.

Consult the 'ps' manpages for the meaning of these fields.

Regards!

...JRF...
Raj D.
Honored Contributor

Re: find out the high process

Gany,
Try this out: same thing with ps :
Yes it is possible to find out.

#To see top 20 processes consuming cpu resource and memory:

# UNIX95=1 ps -e -o pcpu,pid,ppid,args | sort -rn | head -20 # In terms of CPU.

# UNIX95=1 ps -e -o vsz,pid,ppid,args | sort -rn | head -20 # In terms of Memory.


# UNIX95=1 ps -e -o pcpu,pid,ppid,user,args | sort -rn | head -20 # Top CPU Usage + user details.
#---------------------------------------------


Cheers,Have fun!.
Raj,
" If u think u can , If u think u cannot , - You are always Right . "
Benoy Daniel
Trusted Contributor

Re: find out the high process

Glance is another good tool to find out cpu and memory usage.
gany59
Regular Advisor

Re: find out the high process

Hello Folks,

I have two Doubt

1)I used the below command for find out the high process (24889).
In UNIX95 command it showing 20.53 but in TOP 45.84% showing for same PID 24889
is there any differences on that.

UNIX95=1 ps -e -o pcpu,pid,ppid,user,args | sort -rn | head -20
20.53 24889 24880 oracle oracleagentdb (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
10.46 9312 1 oracle /u01/app/oracle/product/9.2/bin/tnslsnr LISTENER -inherit
5.21 6162 1 oracle oracleagentdb (LOCAL=NO)
1.27 4671 4670 root /opt/ignite/bin/print_manifest

==================================

CPU TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU COMMAND
1 ? 24889 aspire 233 22 2440M 34168K run 5:30 45.92 45.84 oracleagentdb
2 ? 9312 oracle 154 20 1610M 1591M sleep 37167:15 10.60 10.58 tnslsnr
4 ? 15246 oracle 154 20 2407M 4100K sleep 0:00 24.37 3.39 oracleagentdb
5 ? 43 root 152 20 7456K 7456K run 12346:24 1.64 1.63 vxfsd
1 ? 15050 aspire 149 22 32K 32K zomb 0:00 1.19 0.73 ssh
2 ? 7881 root 127 20 48180K 16604K sleep 2683:45 0.66 0.66 scopeux
3 ? 7795 root -16 20 40572K 18808K run 22759:32 0.61 0.61 midaemon

===================================================================

2).For the memory usage is used the below command, but the thing is what is 1592700and 9312 in the first and second column

$ UNIX95=1 ps -e -o vsz,pid,ppid,user,args | sort -rn | head -20
1592700 9312 1 oracle /u01/app/oracle/product/9.2/bin/tnslsnr LISTENER -inherit
906540 21807 1 root /opt/tivoli/tsm/client/ba/bin/dsmc sched
531048 7544 1 root /usr/sbin/snmpdm
476800 8014 1 root /opt/VRTSsal/bin/vxsald
121152 16861 1 oracle ora_dbw0_dm2c2hdb
119872 16879 1 oracle ora_mmon_dm2c2hdb
119360 16881 1 oracle ora_mmnl_dm2c2hdb

Can any body clarrify this one, Thanks in advance!!!!!!!
Sujit
Advisor

Re: find out the high process

For CPU

UNIX95= ps -eo user,pid,pcpu,comm | sort -nrbk3 | head -5


For Memory

UNIX95= ps -eo user,pid,vsz,comm | sort -nrbk3 | head -5