Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

2 Answers

up vote 6 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
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

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