How to get the CPU and memory usage of a process in Linux?
Posted in Help the coder! on Aug 3, 2009 at 21:37 IST (12 months ago). Subscribe to this post
Email
Showing comments 1 to 4 of total 4 on page 1 of 1
Post replyShowing comments 1 to 4 of total 4 on page 1 of 1
« Previous1Next »
dheerajRank: 191
I want to get the CPU and memory usage of a single process in Linux(Ubuntu) - I know the PID. What command can I use to get this info from the Linux command-line?
Posted by dheeraj on Monday, August 3, 2009, 9:37 pm
micoohRank: 98
You could use top -b and grep out the pid you want (with the -b flag top runs in batch mode), or also use the -p flag and specify the pid without using grep.
Posted by micooh on Monday, August 3, 2009, 10:24 pm
limcaboyRank: 70
ps -p < pid > -o %cpu,%mem,cmd
(You can leave off "cmd" but that might be helpful in debugging).
Posted by limcaboy on Monday, August 3, 2009, 11:18 pm
manojsRank: 124
To get the memory usage of just your application (as opposed to the shared libraries it uses, you need to use the Linux smaps interface).
Posted by manojs on Monday, August 3, 2009, 11:51 pm
Pages: « Previous1Next »