Limit CPU usage in terms of temperature












7















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



























    7















    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

























      7












      7








      7


      3






      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














      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.)







      temperature






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 3 '12 at 4:18









      jeffythedragonslayerjeffythedragonslayer

      206314




      206314






















          4 Answers
          4






          active

          oldest

          votes


















          7














          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





















          • 2





            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








          • 1





            nice script.. good idea :)

            – Superbiji
            Mar 29 '14 at 3:21






          • 1





            here are essential parts: github.com/Sepero/temp-throttle

            – DmitrySandalov
            Jul 17 '14 at 20:14



















          3














          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.



          #!/bin/bash

          while true; do
          val=$(sensors | awk '/Core 0/ {print $3}')
          max="+60.0"
          if [[ "$val" < "$max" ]]
          then
          killall cpulimit
          sleep .1
          else
          cpulimit -e FahCore_a4 -l 99 &
          sleep 1
          fi
          clear
          sensors
          done





          share|improve this answer

































            0














            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?

              – jeffythedragonslayer
              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



















            0














            This is how I solved my overheating problems which were not caused by a specific process, but by failure of my laptop to dissipate the heat caused by running on a high CPU load for longer periods of time. The main difference to the solution offered by da code monkey himself is that I use cpu frequency scaling, instead of using cpulimit on a specific process. Since I have Psensor installed and running anyway, I piggyback on Psensor. A daemon like da code monkey suggested should also work, however two thresholds (min and max) are required. In Psensor (Sensor Preferences->Alarm) I set an alarm for the relevant sensor if becomes higher than the high threshold (I use 85) or lower than the low threshold (I use 80). In Preferences->Sensors->Script executed when an alarm is raised I call my script heatcontrol.sh like this:



            /ALLUSER/heatcontrol.sh powersave ondemand 82



            The first parameter is a valid scaling_governor which reduces CPU frequency, e.g. powersave. The second parameter is the default scaling_governor - ondemand for most systems. The third parameter is a temperature between low and high threshold (the exact value is not important). Psensor adds two more parameters: a sensor id and the temperature reported.



            And this is my heatcontrol.sh script:



            #!/bin/bash
            # TempNZ is temperature reported by Psensor; strip of trailing °C
            TempNZ=$5
            bnum=`expr index "$TempNZ" "°"`
            if (( bnum < 2 )); then
            echo "ERROR"
            fi
            TempNZ=${TempNZ:0:$(($bnum-1))}
            STR=$1
            # Is this a low threshold alarm?
            if [ "$TempNZ" -le "$3" ]; then
            STR=$2
            fi
            sudo sh -c "echo '$STR' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
            # echo new scaling_governor
            sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
            # play sound - audio feedback - optional
            paplay /usr/share/sounds/ubuntu/stereo/message-new-instant.ogg


            Works fine for me (UBUNTU 14.04 LTS).



            Being a novice to Linux and bash, I used a number of resources, including:



            https://wiki.archlinux.org/index.php/CPU_frequency_scaling



            http://elinux.org/Jetson/Performance#Viewing_the_current_CPU_status






            share|improve this answer

























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "89"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f171397%2flimit-cpu-usage-in-terms-of-temperature%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              4 Answers
              4






              active

              oldest

              votes








              4 Answers
              4






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              7














              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





















              • 2





                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








              • 1





                nice script.. good idea :)

                – Superbiji
                Mar 29 '14 at 3:21






              • 1





                here are essential parts: github.com/Sepero/temp-throttle

                – DmitrySandalov
                Jul 17 '14 at 20:14
















              7














              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





















              • 2





                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








              • 1





                nice script.. good idea :)

                – Superbiji
                Mar 29 '14 at 3:21






              • 1





                here are essential parts: github.com/Sepero/temp-throttle

                – DmitrySandalov
                Jul 17 '14 at 20:14














              7












              7








              7







              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















              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














              share|improve this answer



              share|improve this answer








              edited Dec 25 '13 at 18:38

























              answered Oct 29 '12 at 13:46









              SeperoSepero

              3,26322447




              3,26322447








              • 2





                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








              • 1





                nice script.. good idea :)

                – Superbiji
                Mar 29 '14 at 3:21






              • 1





                here are essential parts: github.com/Sepero/temp-throttle

                – DmitrySandalov
                Jul 17 '14 at 20:14














              • 2





                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








              • 1





                nice script.. good idea :)

                – Superbiji
                Mar 29 '14 at 3:21






              • 1





                here are essential parts: github.com/Sepero/temp-throttle

                – DmitrySandalov
                Jul 17 '14 at 20:14








              2




              2





              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







              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






              1




              1





              nice script.. good idea :)

              – Superbiji
              Mar 29 '14 at 3:21





              nice script.. good idea :)

              – Superbiji
              Mar 29 '14 at 3:21




              1




              1





              here are essential parts: github.com/Sepero/temp-throttle

              – DmitrySandalov
              Jul 17 '14 at 20:14





              here are essential parts: github.com/Sepero/temp-throttle

              – DmitrySandalov
              Jul 17 '14 at 20:14













              3














              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.



              #!/bin/bash

              while true; do
              val=$(sensors | awk '/Core 0/ {print $3}')
              max="+60.0"
              if [[ "$val" < "$max" ]]
              then
              killall cpulimit
              sleep .1
              else
              cpulimit -e FahCore_a4 -l 99 &
              sleep 1
              fi
              clear
              sensors
              done





              share|improve this answer






























                3














                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.



                #!/bin/bash

                while true; do
                val=$(sensors | awk '/Core 0/ {print $3}')
                max="+60.0"
                if [[ "$val" < "$max" ]]
                then
                killall cpulimit
                sleep .1
                else
                cpulimit -e FahCore_a4 -l 99 &
                sleep 1
                fi
                clear
                sensors
                done





                share|improve this answer




























                  3












                  3








                  3







                  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.



                  #!/bin/bash

                  while true; do
                  val=$(sensors | awk '/Core 0/ {print $3}')
                  max="+60.0"
                  if [[ "$val" < "$max" ]]
                  then
                  killall cpulimit
                  sleep .1
                  else
                  cpulimit -e FahCore_a4 -l 99 &
                  sleep 1
                  fi
                  clear
                  sensors
                  done





                  share|improve this answer















                  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.



                  #!/bin/bash

                  while true; do
                  val=$(sensors | awk '/Core 0/ {print $3}')
                  max="+60.0"
                  if [[ "$val" < "$max" ]]
                  then
                  killall cpulimit
                  sleep .1
                  else
                  cpulimit -e FahCore_a4 -l 99 &
                  sleep 1
                  fi
                  clear
                  sensors
                  done






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 21 mins ago









                  wjandrea

                  8,50742259




                  8,50742259










                  answered Aug 4 '12 at 5:48









                  jeffythedragonslayerjeffythedragonslayer

                  206314




                  206314























                      0














                      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?

                        – jeffythedragonslayer
                        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
















                      0














                      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?

                        – jeffythedragonslayer
                        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














                      0












                      0








                      0







                      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













                      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












                      share|improve this answer



                      share|improve this answer










                      answered Aug 3 '12 at 6:11









                      user72421user72421

                      2,251188




                      2,251188













                      • what language would writing such a daemon be easiest in? bash, python, awk?

                        – jeffythedragonslayer
                        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



















                      • what language would writing such a daemon be easiest in? bash, python, awk?

                        – jeffythedragonslayer
                        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

















                      what language would writing such a daemon be easiest in? bash, python, awk?

                      – jeffythedragonslayer
                      Aug 3 '12 at 7:43





                      what language would writing such a daemon be easiest in? bash, python, awk?

                      – jeffythedragonslayer
                      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





                      I'd say bash is the simplest. Here's an example (look at lines 55-66).

                      – Adobe
                      Aug 3 '12 at 14:54











                      0














                      This is how I solved my overheating problems which were not caused by a specific process, but by failure of my laptop to dissipate the heat caused by running on a high CPU load for longer periods of time. The main difference to the solution offered by da code monkey himself is that I use cpu frequency scaling, instead of using cpulimit on a specific process. Since I have Psensor installed and running anyway, I piggyback on Psensor. A daemon like da code monkey suggested should also work, however two thresholds (min and max) are required. In Psensor (Sensor Preferences->Alarm) I set an alarm for the relevant sensor if becomes higher than the high threshold (I use 85) or lower than the low threshold (I use 80). In Preferences->Sensors->Script executed when an alarm is raised I call my script heatcontrol.sh like this:



                      /ALLUSER/heatcontrol.sh powersave ondemand 82



                      The first parameter is a valid scaling_governor which reduces CPU frequency, e.g. powersave. The second parameter is the default scaling_governor - ondemand for most systems. The third parameter is a temperature between low and high threshold (the exact value is not important). Psensor adds two more parameters: a sensor id and the temperature reported.



                      And this is my heatcontrol.sh script:



                      #!/bin/bash
                      # TempNZ is temperature reported by Psensor; strip of trailing °C
                      TempNZ=$5
                      bnum=`expr index "$TempNZ" "°"`
                      if (( bnum < 2 )); then
                      echo "ERROR"
                      fi
                      TempNZ=${TempNZ:0:$(($bnum-1))}
                      STR=$1
                      # Is this a low threshold alarm?
                      if [ "$TempNZ" -le "$3" ]; then
                      STR=$2
                      fi
                      sudo sh -c "echo '$STR' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
                      # echo new scaling_governor
                      sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
                      # play sound - audio feedback - optional
                      paplay /usr/share/sounds/ubuntu/stereo/message-new-instant.ogg


                      Works fine for me (UBUNTU 14.04 LTS).



                      Being a novice to Linux and bash, I used a number of resources, including:



                      https://wiki.archlinux.org/index.php/CPU_frequency_scaling



                      http://elinux.org/Jetson/Performance#Viewing_the_current_CPU_status






                      share|improve this answer






























                        0














                        This is how I solved my overheating problems which were not caused by a specific process, but by failure of my laptop to dissipate the heat caused by running on a high CPU load for longer periods of time. The main difference to the solution offered by da code monkey himself is that I use cpu frequency scaling, instead of using cpulimit on a specific process. Since I have Psensor installed and running anyway, I piggyback on Psensor. A daemon like da code monkey suggested should also work, however two thresholds (min and max) are required. In Psensor (Sensor Preferences->Alarm) I set an alarm for the relevant sensor if becomes higher than the high threshold (I use 85) or lower than the low threshold (I use 80). In Preferences->Sensors->Script executed when an alarm is raised I call my script heatcontrol.sh like this:



                        /ALLUSER/heatcontrol.sh powersave ondemand 82



                        The first parameter is a valid scaling_governor which reduces CPU frequency, e.g. powersave. The second parameter is the default scaling_governor - ondemand for most systems. The third parameter is a temperature between low and high threshold (the exact value is not important). Psensor adds two more parameters: a sensor id and the temperature reported.



                        And this is my heatcontrol.sh script:



                        #!/bin/bash
                        # TempNZ is temperature reported by Psensor; strip of trailing °C
                        TempNZ=$5
                        bnum=`expr index "$TempNZ" "°"`
                        if (( bnum < 2 )); then
                        echo "ERROR"
                        fi
                        TempNZ=${TempNZ:0:$(($bnum-1))}
                        STR=$1
                        # Is this a low threshold alarm?
                        if [ "$TempNZ" -le "$3" ]; then
                        STR=$2
                        fi
                        sudo sh -c "echo '$STR' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
                        # echo new scaling_governor
                        sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
                        # play sound - audio feedback - optional
                        paplay /usr/share/sounds/ubuntu/stereo/message-new-instant.ogg


                        Works fine for me (UBUNTU 14.04 LTS).



                        Being a novice to Linux and bash, I used a number of resources, including:



                        https://wiki.archlinux.org/index.php/CPU_frequency_scaling



                        http://elinux.org/Jetson/Performance#Viewing_the_current_CPU_status






                        share|improve this answer




























                          0












                          0








                          0







                          This is how I solved my overheating problems which were not caused by a specific process, but by failure of my laptop to dissipate the heat caused by running on a high CPU load for longer periods of time. The main difference to the solution offered by da code monkey himself is that I use cpu frequency scaling, instead of using cpulimit on a specific process. Since I have Psensor installed and running anyway, I piggyback on Psensor. A daemon like da code monkey suggested should also work, however two thresholds (min and max) are required. In Psensor (Sensor Preferences->Alarm) I set an alarm for the relevant sensor if becomes higher than the high threshold (I use 85) or lower than the low threshold (I use 80). In Preferences->Sensors->Script executed when an alarm is raised I call my script heatcontrol.sh like this:



                          /ALLUSER/heatcontrol.sh powersave ondemand 82



                          The first parameter is a valid scaling_governor which reduces CPU frequency, e.g. powersave. The second parameter is the default scaling_governor - ondemand for most systems. The third parameter is a temperature between low and high threshold (the exact value is not important). Psensor adds two more parameters: a sensor id and the temperature reported.



                          And this is my heatcontrol.sh script:



                          #!/bin/bash
                          # TempNZ is temperature reported by Psensor; strip of trailing °C
                          TempNZ=$5
                          bnum=`expr index "$TempNZ" "°"`
                          if (( bnum < 2 )); then
                          echo "ERROR"
                          fi
                          TempNZ=${TempNZ:0:$(($bnum-1))}
                          STR=$1
                          # Is this a low threshold alarm?
                          if [ "$TempNZ" -le "$3" ]; then
                          STR=$2
                          fi
                          sudo sh -c "echo '$STR' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
                          # echo new scaling_governor
                          sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
                          # play sound - audio feedback - optional
                          paplay /usr/share/sounds/ubuntu/stereo/message-new-instant.ogg


                          Works fine for me (UBUNTU 14.04 LTS).



                          Being a novice to Linux and bash, I used a number of resources, including:



                          https://wiki.archlinux.org/index.php/CPU_frequency_scaling



                          http://elinux.org/Jetson/Performance#Viewing_the_current_CPU_status






                          share|improve this answer















                          This is how I solved my overheating problems which were not caused by a specific process, but by failure of my laptop to dissipate the heat caused by running on a high CPU load for longer periods of time. The main difference to the solution offered by da code monkey himself is that I use cpu frequency scaling, instead of using cpulimit on a specific process. Since I have Psensor installed and running anyway, I piggyback on Psensor. A daemon like da code monkey suggested should also work, however two thresholds (min and max) are required. In Psensor (Sensor Preferences->Alarm) I set an alarm for the relevant sensor if becomes higher than the high threshold (I use 85) or lower than the low threshold (I use 80). In Preferences->Sensors->Script executed when an alarm is raised I call my script heatcontrol.sh like this:



                          /ALLUSER/heatcontrol.sh powersave ondemand 82



                          The first parameter is a valid scaling_governor which reduces CPU frequency, e.g. powersave. The second parameter is the default scaling_governor - ondemand for most systems. The third parameter is a temperature between low and high threshold (the exact value is not important). Psensor adds two more parameters: a sensor id and the temperature reported.



                          And this is my heatcontrol.sh script:



                          #!/bin/bash
                          # TempNZ is temperature reported by Psensor; strip of trailing °C
                          TempNZ=$5
                          bnum=`expr index "$TempNZ" "°"`
                          if (( bnum < 2 )); then
                          echo "ERROR"
                          fi
                          TempNZ=${TempNZ:0:$(($bnum-1))}
                          STR=$1
                          # Is this a low threshold alarm?
                          if [ "$TempNZ" -le "$3" ]; then
                          STR=$2
                          fi
                          sudo sh -c "echo '$STR' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
                          # echo new scaling_governor
                          sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
                          # play sound - audio feedback - optional
                          paplay /usr/share/sounds/ubuntu/stereo/message-new-instant.ogg


                          Works fine for me (UBUNTU 14.04 LTS).



                          Being a novice to Linux and bash, I used a number of resources, including:



                          https://wiki.archlinux.org/index.php/CPU_frequency_scaling



                          http://elinux.org/Jetson/Performance#Viewing_the_current_CPU_status







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Jan 18 '15 at 12:51

























                          answered Jan 17 '15 at 23:24









                          user369752user369752

                          11




                          11






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Ask Ubuntu!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f171397%2flimit-cpu-usage-in-terms-of-temperature%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              GameSpot

                              日野市

                              Tu-95轟炸機