1

I regularly use time to find out how long a process takes. Is there an equivalent command for memory? The usual ways to find out how much memory a process takes (ps,/proc/meminfo, etc.) work fine for a long-running process, but I don't know of anything that works like time does, for a command run from the command line. I'm imaging something like "size", except that includes the stack and heap:

% mem python myscript.py
   text    data    heap 
3135006  570928  115528
GAD3R
  • 66,769

1 Answers1

0

Below stuff may help :

var=$(pgrep process_name_here);
top -b -p "$var" | awk -v var=$var '$1~var{print $10}'

You might even think of writing a script and passing the process name as argument

Note: This solution will not work if you change the default layout for the top command. In that case you need to replace $10 with appropriate field number

sjsam
  • 1,594
  • 2
  • 14
  • 22