I have a pretty badly ventilated computer whose temperature reaches 100º C in some occasions. The poor thing can't be ventilated any better ("put a bigger fan" is not a suitable solution). When the CPU reaches 100º C, the machine stops "violently" (just shuts down). That machine is running Ubuntu 10.10 with lm-sensors-3 (the installed package is lm-sensors 1:3.1.2-6)

I know what program is causing the issue (a very demanding media player) I could actually stop it for a while without causing major disruptions when the temperature reaches 98º C and boot it again when it reaches... lets say 90º C.

Is that possible to do something like that directly through lm-sensors or do I have to create my own process that checks lm-sensors periodically and "does its things" depending on the temperature?

Thank you in advance.


It depends on what is the output of sensors. If yours is something like mine:

% sensors
Adapter: PCI adapter
temp1:        +44.0°C  (high = +70.0°C)

then you can use the following script, adapting it accordingly. Besides TEMP_STOP and TEMP_START, you should change the regular expression that filters the line from sensors you want to use. It's the parameter to grep, in the temp function.



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

while true; do
    # keep waiting until temp is too hot
    while [ $(echo "$TEMP < $TEMP_STOP" | bc) = 1 ]; do
        sleep 10

    echo temp $TEMP too hot, stopping.

    # now wait for it to cool down...
    while [ $(echo "$TEMP > $TEMP_START" | bc) = 1 ]; do
        sleep 10

    echo ok now, restarting...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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