3

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.

2 Answers2

5

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.

EEAA
  • 108,414
  • 18
  • 172
  • 242
0

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

rettops
  • 101