Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to monitor my CentOS processes using top command to see if there are any processes where CPU usage is greater than X%, below is the command I am using to see if any processes CPU usage is greater than 10%.

top | awk '{if (NF == 14) {
  if ( int($10) >= 10 ) { print $0; system("ps -ef | grep " $13); }
}}' >> top.txt

It seems like the above command will miss some results. While the above command is running, I open another session and execute top command. I have noticed that sometimes when I saw some processes CPU usage are greater than 10%, but the results are not captured via the command above.

Not sure if there are better ways, or I the above script is wrong.

Many thanks!

share|improve this question

1 Answer 1

The top command is not the best choice for parsing data. Try to use sar instead (if not installed by default, run yum install sysstat), or iostat -c.

share|improve this answer

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.