Shell – How to enable safeguards for CPU temperature

cpulinuxshell-scripttemperature

My desktop has a nasty habit. When I have several high intensity applications running and my CPU is at maximum usage for a period of time, the core temperature rises and my computer auto-shuts off.

Is there a way I can monitor (write a script) my CPU temperature in the background and have some sort of warning when it gets above a certain temperature?

I'm running Opensuse with dwm as my window manager. I usually use sensors to see my CPU temperature.

Best Answer

You could write a script to display your temperature in dwm's status bar, for example:

temp (){
    awk '{print $4"°C"}' <(acpi -t)
    echo $temp
}
xsetroot -name "$(temp)"

Your sensors output may be more complex, depending on your setup: this works on one of my machines:

 awk '/temp1/ {print +$2"°C"}' <(sensors)

If you patch in statuscolours, you can additionally have the output change colour as the $temp hits higher values...

The Arch Wiki has an introduction to setting up a basic statusbar script and the dwm site includes an .xinitrc example.

You can see my dwm-status script for more details: http://beta.intuxication.org/jasonwryan/archer/file/tip/Scripts/dwm-status

Related Question