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 Bookmark and Share Email
Showing comments 1 to 4 of total 4 on page 1 of 1
Post reply
« Previous1Next »

dheeraj
Rank: 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
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

micooh
Rank: 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
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

limcaboy
Rank: 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
  • Currently 0.00/5

0 votes

Thank this userFlag this comment

manojs
Rank: 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
  • Currently 0.00/5

0 votes

Thank this userFlag this comment
Pages: « Previous1Next »

Post your comment (No registration required)

  Add my comment  

TechieDesi Community

Not signed in (Sign-in or Register)
Be a true TechieDesi!
Top 10 Users
Spread the word
Invite your friends
Fan stuff
Help us improve
Need Help
FAQ's
Search tips
Found a bug? Report!
Feeds and letters
Subscribe via RSS
Archives
Subscribe to newsletter
Unsubscribe e-mail
Miscellaneous
Privacy policy
Visit rootnerve
About us
About us
Support the development
Official Blog
Advertise with us
Careers
Copyright (c) 2008, TechieDesi.com. All rights reserved | About us | Do-Not-Disturb registry | Powered by rootnerve | Page rendered in 0.130 seconds