SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2012-08-22 15:01:02

ChickenPie4Tea
#! Junkie
Registered: 2012-02-17
Posts: 338

how do you control cpu usage of apps?

on windows there were at least 2 good apps to control the percentage of cpu an app could hog.
so you could set say firefox to only allow it 80% tops, that way your system wouldn't freeze up.
Before anyone says you dont need that on linux - just today it happened to me whilst running a bash script (that uses imagemagick) to rezize a couple of photos
anyone use an app on Crunchbang to control things?

Last edited by ChickenPie4Tea (2012-08-22 15:01:34)


Troll = not a fanatic

Offline

Be excellent to each other!

#2 2012-08-22 15:14:13

fthpl
#! CrunchBanger
From: Turkey
Registered: 2012-06-01
Posts: 150

Re: how do you control cpu usage of apps?

Hi.Usually, i use htop and top smile

You can use gnome system monitor ,lxtaks or xfce system monitor.Make your choose.We have a lots of choices.

htop
htop-1.0-screenshot.png

lxtask
LXTask.png

Use google and look system monitors smile

Last edited by fthpl (2012-08-22 15:14:55)


*Crunchbang Waldorf
*Linux Mint Debian Edition

Offline

#3 2012-08-22 15:21:03

ChickenPie4Tea
#! Junkie
Registered: 2012-02-17
Posts: 338

Re: how do you control cpu usage of apps?

so with htop you can configure it to stop an app using too much cpu? that way you would need to run htop all the time so it could control things?
If you mean you can just bring up htop and then kill a process - how would you do that when your system is not responding because an app has already hogged all the cpu?


Troll = not a fanatic

Offline

#4 2012-08-22 15:22:59

p120d16y
#! Die Hard
From: Midwest
Registered: 2011-08-08
Posts: 800

Re: how do you control cpu usage of apps?

htop is very featureful. You can set filters to allow only certain cpu usage, and many users leave a VT open with htop 24/7 just for process monitoring.


All tyranny needs to gain a foothold is for people of good conscience to remain silent.
---Thomas Jefferson ---

Offline

#5 2012-08-22 15:25:09

ChickenPie4Tea
#! Junkie
Registered: 2012-02-17
Posts: 338

Re: how do you control cpu usage of apps?

p120d16y wrote:

htop is very featureful. You can set filters to allow only certain cpu usage, and many users leave a VT open with htop 24/7 just for process monitoring.

oh well, didn't know that I thought it was just for viewing what was running and killing a process, will play about with it then.


Troll = not a fanatic

Offline

#6 2012-08-22 15:30:20

ivanovnegro
Ivan #000000
From: unstable madness
Registered: 2011-06-02
Posts: 5,322

Re: how do you control cpu usage of apps?

You can kill processes with htop as you can do from the command line in general as with some graphical monitors too.

Offline

#7 2012-08-22 15:32:30

p120d16y
#! Die Hard
From: Midwest
Registered: 2011-08-08
Posts: 800

Re: how do you control cpu usage of apps?

Run htop, run through the filter menu, sort by, etc. and figure out how to set the CPU filter. I don't recall where it is, but I know you can do it. Like fthpl said though, there are many other process managers, task managers, etc. I just don't see going out and snagging a GUI when you've got top already.

Last edited by p120d16y (2012-08-22 15:34:54)


All tyranny needs to gain a foothold is for people of good conscience to remain silent.
---Thomas Jefferson ---

Offline

#8 2012-08-22 18:02:43

El_Belgicano
#! CrunchBanger
Registered: 2011-05-23
Posts: 147

Re: how do you control cpu usage of apps?

cpulimit:

recurring example: cpulimit -e mencoder -l 50 so that mencoder uses no more than 50% of one core...

Offline

#9 2012-08-22 18:40:51

p120d16y
#! Die Hard
From: Midwest
Registered: 2011-08-08
Posts: 800

Re: how do you control cpu usage of apps?

Thanks for the example.

I should refresh on certain terminal commands I very rarely use.


All tyranny needs to gain a foothold is for people of good conscience to remain silent.
---Thomas Jefferson ---

Offline

#10 2012-08-23 09:17:16

ChickenPie4Tea
#! Junkie
Registered: 2012-02-17
Posts: 338

Re: how do you control cpu usage of apps?

El_Belgicano wrote:

cpulimit:

recurring example: cpulimit -e mencoder -l 50 so that mencoder uses no more than 50% of one core...

Thanks very handy to know, I looked at htop but couldn't find how to do it with it.


Troll = not a fanatic

Offline

#11 2012-08-23 09:27:19

GamBit
#! CrunchBanger
From: Vienna/Austria
Registered: 2012-07-22
Posts: 104

Re: how do you control cpu usage of apps?

you can also take a look at the "nice"  command.

Type in your shell

info coreutils 'nice invocation'

for more information.

Offline

#12 2012-08-23 12:30:10

VDP76
#! Junkie
From: Bayreuth, Germany
Registered: 2012-04-12
Posts: 454

Re: how do you control cpu usage of apps?

ChickenPie4Tea wrote:

so with htop you can configure it to stop an app using too much cpu? that way you would need to run htop all the time so it could control things?
If you mean you can just bring up htop and then kill a process - how would you do that when your system is not responding because an app has already hogged all the cpu?

if you know which applications are usually to blame you can just terminate them with Openbox keybindings, like

<keybind key="C-W-t">
<action name="Execute">
<command>kill -9 $(pidof application_name)</command>
</action>
</keybind>

for example I have set one to terminate chrome that sometimes slows down everything.. hmm

Last edited by VDP76 (2012-08-23 12:30:40)


We are a nice, friendly community here and I hope we stay that way.. smile

Offline

#13 2012-08-23 13:37:04

machinebacon
#! unstable
From: PRC
Registered: 2009-07-02
Posts: 6,271
Website

Re: how do you control cpu usage of apps?

GamBit wrote:

you can also take a look at the "nice"  command.

Type in your shell

info coreutils 'nice invocation'

for more information.

This is it. Process priority, and not CPU capping: http://everyjoe.com/technology/howto-ch … e-command/


Start Distrohopping here! -> Roast your ownVSIDO | LinuxCNC | AntiX | <-

Keep it what way?

Offline

#14 2012-08-23 14:06:31

Awebb
The Singularity
Registered: 2009-07-23
Posts: 2,812

Re: how do you control cpu usage of apps?

Yes, use nice. Limiting CPU usage for a certain binary will slow your system down and use way more energy in the long run.


I'm so meta, even this acronym

Offline

#15 2012-08-23 14:10:05

ChickenPie4Tea
#! Junkie
Registered: 2012-02-17
Posts: 338

Re: how do you control cpu usage of apps?

thanks for the link MachineBacon - although I notice the comment someone left at the bottom of the page to say the author was wrong with his examle.

ok so if I wanted to use the nice command in a script to reduce the priority would this be right?

#!/bin/bash
nice -10 ./zim-start.sh &

Last edited by ChickenPie4Tea (2012-08-23 14:32:40)


Troll = not a fanatic

Offline

#16 2012-08-23 20:36:08

jens
#! Junkie
Registered: 2012-01-11
Posts: 453

Re: how do you control cpu usage of apps?

i also use htop, of course.
and my dual-core notebook, which is capable of running at 1.6 GHz at max, is throttled down to 800 MHz permanently.
this keeps CPU temps low, thus the fan does not make siren noises. i never need the full performance for my daily work.


evilwm = digital zen

Offline

#17 2012-08-24 00:56:38

afab4
Member
From: Stony Lake, Michigan
Registered: 2012-08-16
Posts: 23

Re: how do you control cpu usage of apps?

I use cpulimit.  Works very well while remastering to keep my cpu (s) from going to 100% and overheating my laptop.
Here is a very nice "how to" written by abcuser on the ubuntu forums.
http://ubuntuforums.org/showthread.php?t=992706hmm


I support the candidate that will steal the least from me....

Offline

#18 2012-08-24 07:24:14

ChickenPie4Tea
#! Junkie
Registered: 2012-02-17
Posts: 338

Re: how do you control cpu usage of apps?

afab4 wrote:

I use cpulimit.  Works very well while remastering to keep my cpu (s) from going to 100% and overheating my laptop.
Here is a very nice "how to" written by abcuser on the ubuntu forums.
http://ubuntuforums.org/showthread.php?t=992706hmm

Thanks afab4  I followed the guide exactly but when  it got to
"Add script to boot-up procedure directories"
sudo update-rc.d cpulimit defaults

terminal gave the message
"update-rc.d: using dependency based boot sequencing
insserv: warning: script 'cpulimit' missing LSB tags and overrides"
(however I notice despite the message that the daemon does start on system startup)

Trying to start it manually as the guide told - I got the message
cpulimit daemon can not be started

however I notice despite the message that the daemon does start on system startup
Think I'm going to have to exclude Iceweasel from the 20% of cpu limint though as it is noticably slow

Last edited by ChickenPie4Tea (2012-08-24 08:02:36)


Troll = not a fanatic

Offline

#19 2012-08-24 10:05:49

El_Belgicano
#! CrunchBanger
Registered: 2011-05-23
Posts: 147

Re: how do you control cpu usage of apps?

ChickenPie4Tea wrote:

<snip>
Trying to start it manually as the guide told - I got the message
cpulimit daemon can not be started

however I notice despite the message that the daemon does start on system startup
<snip>

I followed the same guide and had the very same "problem":

start)
if [ $(ps -eo pid,args | gawk '$3=="/usr/bin/cpulimit_daemon.sh"  {print $1}' | wc -l) -eq 0 ]; then
    nohup /usr/bin/cpulimit_daemon.sh >/dev/null 2>&1 &
    sleep 1 # I added this to delay the next command.
    ps -eo pid,args | gawk '$3=="/usr/bin/cpulimit_daemon.sh"  {print}' | wc -l | gawk '{ if ($1 == 1) print " * cpulimit daemon started successfully"; else print " * cpulimit daemon can not be started" }'
else
    echo " * cpulimit daemon can't be started, because it is already running"
fi
;;

This is because when issuing "sudo service cpulimit start" it would tell me "daemon not started" but doing "sudo service cpulimit status" right after would tell me it is actually running, sleep 1 fixes this...

Last edited by El_Belgicano (2012-08-24 10:09:03)

Offline

#20 2012-08-24 15:17:22

afab4
Member
From: Stony Lake, Michigan
Registered: 2012-08-16
Posts: 23

Re: how do you control cpu usage of apps?

ChickenPie4Tea wrote:

Thanks afab4  I followed the guide exactly but when  it got to
"Add script to boot-up procedure directories"
sudo update-rc.d cpulimit defaults

terminal gave the message
"update-rc.d: using dependency based boot sequencing
insserv: warning: script 'cpulimit' missing LSB tags and overrides"
(however I notice despite the message that the daemon does start on system startup)

Trying to start it manually as the guide told - I got the message
cpulimit daemon can not be started

however I notice despite the message that the daemon does start on system startup
Think I'm going to have to exclude Iceweasel from the 20% of cpu limint though as it is noticably slow

Yes, I got the same insserv:warning messages but as you stated the daemon does start.
I set variables in my cpulimit_daemon.sh like this:

# Variables
CPU_LIMIT=80           # Maximum percentage CPU consumption by each PID
DAEMON_INTERVAL=3      # Daemon check interval in seconds
BLACK_PROCESSES_LIST= "mksquashfs|rsync|genisoimage"   # Limit only processes defined in this variable. If variable is empty (default) all violating processes are limited.
WHITE_PROCESSES_LIST=   # Limit all processes except processes defined in this variable. If variable is empty (default) all violating processes are limited.
This allows my Core2 Duo CPU P9400 to run about 40% while remastering and keeps my cpu temp around 155 F.

Last edited by afab4 (2012-08-24 15:19:01)


I support the candidate that will steal the least from me....

Offline

#21 2012-08-24 15:40:49

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,491

Re: how do you control cpu usage of apps?

Warning

insserv: warning: script 'cpulimit' missing LSB tags and overrides"

You guys will probably run into  trouble next time you want to add a system service.
The LSB tags are used to figure out in what order the system services should be started.
The absence of LSB tags makes this impossible. It can cause update-rc.d to go into a loop.

Offline

#22 2012-08-24 17:01:58

afab4
Member
From: Stony Lake, Michigan
Registered: 2012-08-16
Posts: 23

Re: how do you control cpu usage of apps?

xaos52 wrote:

Warning

insserv: warning: script 'cpulimit' missing LSB tags and overrides"

You guys will probably run into  trouble next time you want to add a system service.
The LSB tags are used to figure out in what order the system services should be started.
The absence of LSB tags makes this impossible. It can cause update-rc.d to go into a loop.

So would adding this header to the cpulimit script in /etc/init.d as such do the job?

#!/bin/sh
#
### BEGIN INIT INFO
# Provides:          cpulimit
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      
# Short-Description: Script to start CPU limit daemon
### END INIT INFO

This is the format and run levels used in the irqbalance script.


I support the candidate that will steal the least from me....

Offline

#23 2012-08-24 17:16:50

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,491

Re: how do you control cpu usage of apps?

I suppose it would, yes.
You can test this by
☆ editing the script
☆ removing the service cpulimit

sudo update-rc.d cpulimit disable

☆ adding the service again

sudo update-rc.d cpulimit enable

Last edited by xaos52 (2012-08-24 17:21:06)

Offline

#24 2012-08-24 20:13:18

afab4
Member
From: Stony Lake, Michigan
Registered: 2012-08-16
Posts: 23

Re: how do you control cpu usage of apps?

xaos52 wrote:

I suppose it would, yes.
You can test this by
☆ editing the script
☆ removing the service cpulimit

sudo update-rc.d cpulimit disable

☆ adding the service again

sudo update-rc.d cpulimit enable

I tried this and still got errors about the current runlevels for stop conflicting with the new script.   After fiddling around with the header I came up with this:

### BEGIN INIT INFO
# Provides:          cpulimit
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5 
# Default-Stop:      0 1 6
# Short-Description: Script to start and stop CPU limit daemon
### END INIT INFO

then ran:

sudo update-rc.d cpulimit defaults

and no more error message.


I support the candidate that will steal the least from me....

Offline

Be excellent to each other!

#25 2012-08-25 09:06:39

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,491

Re: how do you control cpu usage of apps?

That should be OK.
Thanks for the feedback.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo