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 run distributed computing projects, which typically want to use 100% of the CPU. How do I limit the CPU usage in terms of temperature instead of percent usage? Also, what is the maximum safe temperature to keep an Intel i5 running 24/7? (With no CPU limit FahCore_a4 causes this machine to run at 82 degrees Celsius.)

share|improve this question

3 Answers 3

The CPU itsself has a mechanism where it powers itsself down if it gets too hot. (maybe not if you disable SMI interrupts, I'm not sure about that.)

The main user-space application is the lm-sensors package. After installing it run sensors-detect to set it up, if your machines are the same you can run this once, and use the resulting findings everywhere.

CPU frequency is easily controled via the cpufreq driver subsystem. see https://wiki.archlinux.org/index.php/CPU_Frequency_Scaling

You could write a daemon that uses lm-sensors to poll the temp and if its too hot turn down the cpu frequency.

share|improve this answer
what language would writing such a daemon be easiest in? bash, python, awk? –  da code monkey Aug 3 '12 at 7:43
I'd say bash is the simplest. Here's an example (look at lines 55-66). –  Adobe Aug 3 '12 at 14:54

Here is how I solved it using bash. If anyone comes up with a better daemon (better at staying near the target temperature) please post it.


    while true; do
            val=$(sensors | awk '/Core 0/ {print $3}')
            max=$(echo "+60.0")
            if [[ "$val" < "$max" ]]
                            killall cpulimit
                            sleep .1
                            cpulimit -e FahCore_a4 -l 99 &
                            sleep 1
    exit 0
share|improve this answer

On this webpage there is a bash script that will attempt to keep your CPU below a specified temperature. http://seperohacker.blogspot.com/2012/10/linux-keep-your-cpu-cool-with-frequency.html

You just need to provide it with your desired maximum temperature, and it will throttle your CPU(s) in an effort to stay below that temperature.

Shameless plug- I wrote and maintain the above script.

share|improve this answer
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  fossfreedom Nov 19 '12 at 16:47
nice script.. good idea :) –  Superbiji Mar 29 at 3:21
here are essential parts: github.com/Sepero/temp-throttle –  DmitrySandalov Jul 17 at 20:14

Your Answer


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.