Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 know that after running top, I can press '1' and get a list of the CPUs with their utilization percentages. I suspect I can do this in batch mode too with the -b option, but I don't know how, and I cannot find it in the manual.

I need to read it periodically from a python program, so it must be in batch mode.

share|improve this question
I may have a workaround for you here: – AXE-Labs Jan 23 '15 at 23:14
up vote 7 down vote accepted

You can use a configuration file for this. The easiest way is to open top, and configure it the way you want. In this case, that means using '1' to get the per-CPU listing. Then have it write a configuration file with W. (Note the caps -- gotta use shift) After that, it will use that config file whenever that user runs top, and keep the same appearance, even in batch mode.

Note that you'll probably need a $HOME variable defined, if you're using this via cron, or some other environment lacking the standard login definitions.

--Christopher Karel

share|improve this answer

I am not familiar with a way to do that with top, but you might have a look at mpstat which will show cpu utilization per core.

share|improve this answer
My system doesn't appear to have that, and I cannot install anything :( – Nathan Jun 22 '10 at 17:41

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.