Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 17 Apr 2014, 23:19
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Question re a CPU throttling script
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
thelaptopkiller

Joined: 25 Oct 2009
Posts: 67
Location: The only place in tornado ally with no tornadoes

PostPosted: Sat 31 Oct 2009, 10:06    Post subject:  Question re a CPU throttling script  

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:
#$/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
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2167

PostPosted: Sat 31 Oct 2009, 12:22    Post subject:  

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.
Back to top
View user's profile Send private message 
thelaptopkiller

Joined: 25 Oct 2009
Posts: 67
Location: The only place in tornado ally with no tornadoes

PostPosted: Sat 31 Oct 2009, 20:04    Post subject:  thanks man  

thanks for the help man!
It was just a "tipo" Laughing
I needed help anyway with the coding.
(so thats why my scripts wont work...) Laughing
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0407s ][ Queries: 11 (0.0060s) ][ GZIP on ]