Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to monitor one process' CPU usage and RAM usage over time on linux? I am trying to change to a cheaper VPS and need to work out what level of CPU and RAM I need!

share|improve this question
Shouldn't you be more interested in maximum memory usage? – Ryan Thompson Nov 15 '10 at 0:49
up vote 5 down vote accepted

read man 5 proc, especially the /proc/[pid]/stat entry and the utime, stime fields. /proc/[pid]/status or /proc/[pid]/statm might be of interest for you as well.

then use cron or whatever means needed to collect 'snapshots' of /proc/[pid]/stat for your process over a period of time. then visualize what you have grabbed.

a simple 'collector' works like this (for a process with the pid '29777'):

% while true; do cat /proc/29777/stat; sleep 1; done

to make life easier, you could also use the systat package which includes several means to collect data over time:

share|improve this answer
Sounds an interesting idea, i'll give it a go and update you with the result. – Pez Cuckow Nov 16 '10 at 18:57

pidstat is a very good tool for the cpu part of your question.

share|improve this answer

top command should give you all the info you need.

share|improve this answer
Top only provides instantaneous snapshots of CPU and memory usage. The OP asks how to collect aggregate statistics over time. – Ryan Thompson Nov 15 '10 at 0:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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