1831919 Members
3276 Online
110031 Solutions
New Discussion

Total process size

 
SOLVED
Go to solution
Mahesh Kurse
Occasional Contributor

Total process size

Hello !

This seems to be a trivial question :-)

How do I get the total memory size occupied by a process through a command ? I want to use this in a script. '-l' option of 'ps' command gives the resident size but not the actual size. 'top' and 'glance' give the output but I can not use these commands in a script.

Thank you very much !
4 REPLIES 4
Chris Wilshaw
Honored Contributor
Solution

Re: Total process size

You could try

UNIX95= ps -p -ovsz

This will give you the size in KB used by the process with number PID
Ken Hubnik_2
Honored Contributor

Re: Total process size

UNIX95= ps -e -o vsz,ruser,pid,args | sort -rn
Rusty Sapper
Frequent Advisor

Re: Total process size

Actually, you can use top in a script, by using the -n (number of processes to show) and -f (output to text file).

If you know the PID, you can awk out the size field with something like this.

top -n 200 -f /tmp/top.out
grep $PID /tmp/top.out | awk '{print $7}'

HTH

Rusty
James R. Ferguson
Acclaimed Contributor

Re: Total process size

Hi:

'top' has a not-so-well-documented option to allow data collection into a file:

# top -d1 -f /tmp/topshot

Regards!

...JRF...