Server Fault is a question and answer site for system and network administrators. 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

I want to write some scripts that will measure the CPU use, but top's output, while pleasant for the user, isn't really feasible for processing in a script.

share|improve this question
up vote 5 down vote accepted

Check $ man proc. /proc has a subdirectory for each pid on the system. Under each of those is a "stat" file, which includes CPU usage information for that specific pid.

share|improve this answer

If you want information about CPU usage across a span of time, take a look at the mpstat command.

share|improve this answer

Your Answer


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