Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am new to scripting and linux, my comp gets too hot sometimes and I want to make a script to detect temp1 and if it's over 65 C, it must put it to sleep. I have a diffuculty at comparing values in the script, I couldn't manage to define figures correctly, would anybody fix it please? Here is my stab at it so far

#!/bin/bash

max=65

val=$   sensors | grep '^temp1:' | sed -e 's/.*: \+\([+-][0-9.]\+\)°C.*$/0\1/'

while true; do

if [[ "$val" > "$max" ]]
              then
                sudo /etc/acpi/sleep.sh force
                        sleep 1
                else sleep 10
        fi

        clear
        sensors
done
share|improve this question

1 Answer 1

I managed to make my own script.

 #!/bin/bash

 while true; do
        val=$(sensors | awk '/temp1/ {print $2}')
        max=$(echo "+75.0")
        if [[ "$val" > "$max" ]]
                then
                        sudo /etc/acpi/sleep.sh force
                        sleep 10
                else

                        sleep 10
        fi
        clear
        sensors
 done
 exit 0
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.