SEARCH

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

You are not logged in.

#26 2012-08-25 11:33:15

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

Re: how do you control cpu usage of apps?

xaos52 wrote:

That should be OK.
Thanks for the feedback.

And thank you for educating me on LSB tags. smile


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

Offline

Be excellent to each other!

#27 2012-08-25 20:47:16

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

Re: how do you control cpu usage of apps?

afab4 wrote:
xaos52 wrote:

That should be OK.
Thanks for the feedback.

And thank you for educating me on LSB tags. smile

And thank you for the header solution

Last edited by ChickenPie4Tea (2012-08-25 20:47:41)


Troll = not a fanatic

Offline

#28 2012-10-04 22:50:50

brettgavin
New Member
Registered: 2012-10-04
Posts: 2

Re: how do you control cpu usage of apps?

Hi,

I'm trying to get the cpulimit script to run, but I'm running into the same "daemon can not be started" error/output. Would somebody mind taking a look and tell me what I may have mistyped?

It is located here: /etc/init.d/cpulimit

ls -all reports this:
-rwxr-xr-x 1 root root 1947 Oct  4 15:40 /etc/init.d/cpulimit

cpulimit contents:

#!/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:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO        
#
#located @ /etc/init.d/cpulimit
#
# Script to start CPU limit daemon
#
set -e

case "$1" in
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 &
    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
;;
stop)
CPULIMIT_DAEMON=$(ps -eo pid,args | gawk '$3=="/usr/bin/cpulimit_daemon.sh"  {print $1}' | wc -l)
CPULIMIT_INSTANCE=$(ps -eo pid,args | gawk '$2=="cpulimit" {print $1}' | wc -l)
CPULIMIT_ALL=$((CPULIMIT_DAEMON + CPULIMIT_INSTANCE))
if [ $CPULIMIT_ALL -gt 0 ]; then
    if [ $CPULIMIT_DAEMON -gt 0 ]; then
        ps -eo pid,args | gawk '$3=="/usr/bin/cpulimit_daemon.sh"  {print $1}' | xargs kill -9   # kill cpulimit daemon
    fi

    if [ $CPULIMIT_INSTANCE -gt 0 ]; then
        ps -eo pid,args | gawk '$2=="cpulimit" {print $1}' | xargs kill -9                    # release cpulimited process to normal priority
    fi
    ps -eo pid,args | gawk '$3=="/usr/bin/cpulimit_daemon.sh"  {print}' | wc -l | gawk '{ if ($1 == 1) print " * cpulimit daemon can not be stopped"; else print " * cpulimit daemon stopped successfully" }'
else
    echo " * cpulimit daemon can't be stopped, because it is not running"
fi
;;
restart)
$0 stop
sleep 3
$0 start
;;
status)
ps -eo pid,args | gawk '$3=="/usr/bin/cpulimit_daemon.sh"  {print}' | wc -l | gawk '{ if ($1 == 1) print " * cpulimit daemon is running"; else print " * cpulimit daemon is not running" }'
;;
esac
exit 0

Any help would be appreciated!

Thank you

Offline

#29 2012-10-04 22:51:04

brettgavin
New Member
Registered: 2012-10-04
Posts: 2

Re: how do you control cpu usage of apps?

Nevermind. Found a copy paste error. Thanks anyway.



Hi,

I'm trying to get the cpulimit script to run, but I'm running into the same "daemon can not be started" error/output. Would somebody mind taking a look and tell me what I may have mistyped?

It is located here: /etc/init.d/cpulimit

ls -all reports this:
-rwxr-xr-x 1 root root 1947 Oct  4 15:40 /etc/init.d/cpulimit

cpulimit contents:

#!/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:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO        
#
#located @ /etc/init.d/cpulimit
#
# Script to start CPU limit daemon
#
set -e

case "$1" in
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 &
    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
;;
stop)
CPULIMIT_DAEMON=$(ps -eo pid,args | gawk '$3=="/usr/bin/cpulimit_daemon.sh"  {print $1}' | wc -l)
CPULIMIT_INSTANCE=$(ps -eo pid,args | gawk '$2=="cpulimit" {print $1}' | wc -l)
CPULIMIT_ALL=$((CPULIMIT_DAEMON + CPULIMIT_INSTANCE))
if [ $CPULIMIT_ALL -gt 0 ]; then
    if [ $CPULIMIT_DAEMON -gt 0 ]; then
        ps -eo pid,args | gawk '$3=="/usr/bin/cpulimit_daemon.sh"  {print $1}' | xargs kill -9   # kill cpulimit daemon
    fi

    if [ $CPULIMIT_INSTANCE -gt 0 ]; then
        ps -eo pid,args | gawk '$2=="cpulimit" {print $1}' | xargs kill -9                    # release cpulimited process to normal priority
    fi
    ps -eo pid,args | gawk '$3=="/usr/bin/cpulimit_daemon.sh"  {print}' | wc -l | gawk '{ if ($1 == 1) print " * cpulimit daemon can not be stopped"; else print " * cpulimit daemon stopped successfully" }'
else
    echo " * cpulimit daemon can't be stopped, because it is not running"
fi
;;
restart)
$0 stop
sleep 3
$0 start
;;
status)
ps -eo pid,args | gawk '$3=="/usr/bin/cpulimit_daemon.sh"  {print}' | wc -l | gawk '{ if ($1 == 1) print " * cpulimit daemon is running"; else print " * cpulimit daemon is not running" }'
;;
esac
exit 0

Any help would be appreciated!

Thank you

Last edited by brettgavin (2012-10-04 23:17:47)

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