LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-06-2012, 03:12 PM   #1
Find
Member
 
Registered: Jan 2012
Posts: 32

Rep: Reputation: Disabled
Pause first 10, top cpu using programs


How would I pause all top 10 cpu cycle using programs for 2 seconds?
 
Old 03-06-2012, 03:38 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 476Reputation: 476Reputation: 476Reputation: 476Reputation: 476
@ Reply

Hi Find,

What exactly are you trying to do? Can you explain it with the help of an example?
 
Old 03-06-2012, 05:11 PM   #3
Find
Member
 
Registered: Jan 2012
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by T3RM1NVT0R View Post
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.
 
Old 03-07-2012, 01:07 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,252

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
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?
 
Old 03-07-2012, 01:58 AM   #5
Find
Member
 
Registered: Jan 2012
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by chrism01 View Post
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 View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
TOP output Cpu(s) and %CPU don't fit on single core AchimRS Linux - General 2 11-03-2011 04:32 PM
CPU% in top ahmedb72 Linux - General 5 09-11-2010 11:42 AM
Finding the top CPU-using processes? "top" command does not help... catalytical Linux - Server 1 04-06-2009 05:50 PM
[C/C++] pause and cpu usage Hyakutake Programming 5 02-17-2007 08:29 AM
see one cpu instead 2 with hyperthreading in top? balki Linux - Hardware 5 06-22-2004 04:14 AM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration