LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Pause first 10, top cpu using programs (https://www.linuxquestions.org/questions/linux-newbie-8/pause-first-10-top-cpu-using-programs-933065/)

Find 03-06-2012 02:12 PM

Pause first 10, top cpu using programs
 
How would I pause all top 10 cpu cycle using programs for 2 seconds?

T3RM1NVT0R 03-06-2012 02:38 PM

@ Reply
 
Hi Find,

What exactly are you trying to do? Can you explain it with the help of an example?

Find 03-06-2012 04:11 PM

Quote:

Originally Posted by T3RM1NVT0R (Post 4620176)
Hi Find,

What exactly are you trying to do? Can you explain it with the help of an example?

Hi T3RM1NVT0R, I am trying to do the following:
  1. Find which programs are using the cpu the most, ranked from greatest use to least use
  2. Ignore all but the top 10
  3. issue some type of pause command to those top 10
  4. wait 2 seconds
  5. issue some type of resume command

I am guessing this would use bash, top, and grep, but I'm not sure how exactly.

chrism01 03-07-2012 12:07 AM

Well, using this http://linux.die.net/man/1/top I'd start with something like
Code:

top -b -n 1 >top.lst
then parse the results.
You'd need to ensure you don't stop anything to do with the OS itself ...

Why do you need to do this?

Find 03-07-2012 12:58 AM

Quote:

Originally Posted by chrism01 (Post 4620490)
Well, using this http://linux.die.net/man/1/top I'd start with something like
Code:

top -b -n 1 >top.lst
then parse the results.
You'd need to ensure you don't stop anything to do with the OS itself ...

How do I ensure this? Other than making sure I don't pause anything started by the super-user, what else do I check?

Quote:

Originally Posted by chrism01 (Post 4620490)
Why do you need to do this?

I need this to deal with run away programs. Normally CPU on-demand is fine for dealing with programs, heat, and various binary blob programs which I have to work with. But sometimes stuff goes into 'oh I need to take up all the processing time on nothing' loop and the result is a system lockup (and potential fire hazard). This would be a solution to that, and could be run by sensors.


All times are GMT -5. The time now is 01:53 AM.