1

This question already has an answer here:

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

marked as duplicate by Wildcard, Jeff Schaller, heemayl, slm May 3 '16 at 4:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Yes indeed, it is. Thanks for the pointer! – Scott Deerwester May 3 '16 at 3:46
  • You should be able to click the "Yes, this answered my question!" button to mark this one as a duplicate, then. Glad I could help. :) – Wildcard May 3 '16 at 4:07
  • I don't see where to do that. – Scott Deerwester May 4 '16 at 14:38
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

Not the answer you're looking for? Browse other questions tagged or ask your own question.