Question re a CPU throttling script

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
thelaptopkiller
Posts: 66
Joined: Sun 25 Oct 2009, 14:23
Location: The only place in tornado ally with no tornadoes

Question re a CPU throttling script

#1 Post by thelaptopkiller »

I have been working on a cpu throttling script(no duh).
But I need a commandline version of the cpu throddler program in 4.3.2.
The code is

Code: Select all

#$/bin/bash
#this is a forever loop
done1="no"
done2="no"
modprobe fan
modprobe thermal #NEED this for script to work
loop="0"
while $loop = "o" do
   temp=`cat /proc/acpi/thermal_zone/THRM/temperature`
   if [ $temp > "80 C" ] ; then
     if [ $done1 = "no" ] ; then
        #so if the cpu(s) get to 80 c then the thoddler app would 
        #lower the speed.
        #command for cpu throddler app here
        done1="yes"
        done2="no"
     fi 
   fi
   if [ $temp > "75 C" ] ; then
    if [ $done2 = "no" ] ; then
       #so if the cpu(s) get to 75 c then the thoddler app would 
       #increase the speed.
       #command for cpu throddler app here
       done2="yes"
       done1="no"
    fi
  fi
loop
Think this will work coding wise?
I cant try it et because im still working on getting 4.3.2 to work

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#2 Post by amigo »

A couple of obvious problems:
#$/bin/bash
should be:
#!/bin/bash

while $loop = "o" do
should be:
while [ $loop = "0" ] ; do
but since it is an infinte loop you can just do this:
while : ; do

You'll want to put a sleep command in there somewhere, otherwise this loop will run as fast as your processor will let it go. use a sleep to make itstop after checking/adjusting so that it waits some time before checking again. the longer you sleep the less resources this thing will use -probably 5-30 seconds would be adequate

You may need to elimnate the ' C' from the temp measured so taht shell math can really tell if temp is greater than something:
temp=`cat /proc/acpi/thermal_zone/THRM/temperature |cut -f -d' '`
then:
if [ $temp -gt 80 ] ; then

The word is 'throttle' in case you need to search for programs, etc.

thelaptopkiller
Posts: 66
Joined: Sun 25 Oct 2009, 14:23
Location: The only place in tornado ally with no tornadoes

thanks man

#3 Post by thelaptopkiller »

thanks for the help man!
It was just a "tipo" :lol:
I needed help anyway with the coding.
(so thats why my scripts wont work...) :lol:

Post Reply