Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
1  
Under Linux, or some other unix variants? The method to obtain the temperature or be notified of temperature changes differs between unix variants. –  Gilles Nov 19 '11 at 23:22
    
My bad @Gilles, I added information to my question –  maxmackie Nov 19 '11 at 23:40
    
After you see that temperature rise you should throttle down your CPU. –  Nils Nov 20 '11 at 21:07

3 Answers 3

up vote 4 down vote accepted

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

share|improve this answer
    
This is a really great idea that I didn't think of. I never really had time to play around with dwm's statusbar so this will be fun. I'll see what I can manage and comment back. –  maxmackie Nov 20 '11 at 0:47
    
Worked perfectly, and now I have a nicely customized statusbar :) –  maxmackie Nov 20 '11 at 7:32
    
Excellent: it gives you quite a bit of scope to work with... –  jasonwryan Nov 20 '11 at 7:52

I have exactly the same problem and what I use is the "cpufreqtools" (or just "cpufreq" - can't remember!) package.

It gives you two commands: cpufreq-info and cpufreq-set

cpufreq-info list the current CPU speed and the min and max speeds. and the available steps too.

cpufreq-set is more useful for you because you can limit the maximum speed that your CPU will ever reach.

My overheat-prone CPU has the available speeds of 800MHz, 1.60GHz and 1.80GHz. SO, what I do is limit it to 1.60GHz like this:

cpufreq-set --max 1.60Ghz

Works like a charm!

If you are more advanced in your Linux skills, you could even put it in a bootup script so it's always executed as soon as your Linux starts.

Good luck.

share|improve this answer

I created a script to directly address this type of overheating problem. Limit your CPU based on a desired temperature. It runs automatically in the background like this:

sudo ./temp_throttle.sh 80

That command will make your CPU cores slow down when they reach 80 degrees Celsius. When the temperature goes down, the CPU cores will be allowed to run faster again. You can find temp_throttle here.

share|improve this answer
    
In the future, please do not expect everyone running Ubuntu with its default sudo-everything policy. Either mention that one has to allow the script in sudo configuration or (better) just write that it requires root privileges which may be achieved through sudo. Or - on Linux - describe the capabilities (as in the capabilities(7) man page) required. –  peterph Jul 19 at 7:57

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.