Monday, October 29, 2012

Linux: Cool your CPU temperature with frequency throttling

Last night I went to sleep while running a heavy program that used 100% of my Intel i7 multicore processor. When I woke up in the morning, I found my laptop powered off. A look through the /var/log/syslog confirmed that it had shut off due to over heating.

So to control temperature, I wrote a script to throttle cpu frequency. This script must be run with root privileges (sudo) to work. For a desired max temperature of 80 degrees Celsius, use a command like this:
sudo ./ 80

This can also result in longer battery life on laptops and portable devices.

Download link: temperature throttling script for Linux -
New User Resources:

Download link: temperature throttling script for Linux -

Project source page:

NOTICE: This script may not be effective if your system over heating is due to factors other than your CPU (ie. graphics, harddrive, etc.). This script will only throttle your CPU frequency based on your systems reported temperature. Opening and cleaning dust from a computer can often dramatically help cool it also.

If this script helps you in any way, please pay me with a message of thanks, and share this page with others.

Comment or leave feedback sepero 111 @ gmx . com

overheating cpu scaling temperature control Linux


  1. Hi, nice script! umm, my /sys/class/hwmon/hwmon0/temp1_input
    always reports 42 C, so I changed that line to
    TEMP=$(cat /sys/class/hwmon/hwmon1/device/temp1_input)
    that reports the temp the same as my gkrellm lm_sensors CPU temp monitor.


    1. Thanks for the info, Willem. I've updated the code to hopefully accommodate more people.

    2. I am running Fedora 19 and I had to change that path to
      Please note that the device directory does not have temp1_input. This took a little while for me to figure out.

      After I changed this my machine runs beautifully. Also, Pedro's method for running the script as root worked wonders.

      This makes my machine usable again. I also have an i7 but my biggest has always been that it will burn up to the critical temperature and shut off.

      Thanks so much!

  2. Finally! I've found you!
    I published your script at I wanted to ask your permission, but lost your blog :) Sorry.

    And more.
    Some people have even more problems, their kernel module for cpu frequency controlling not loading automatically. I have seen it on arch, mandriva/mageia/rosa, fedora, opensuse (hey! they all rpm distros!) and if you work on laptop without frequency control - huh, it gets hot!
    I don't want to dig deeper into why is this happening, I just wrote autostart script for starting your script with automatic detection if selected module loaded and loading module with selected governor.
    Script was written for RosaLinux/Mageia/Mandriva/Fedora, but I think you can easilly adopt it for Ubuntu or anything else (only change path to /sys/.../cpufreq folder and change comand cpupower to cpufreq-set (or write your own :) )

  3. Hi Russian friend, thank you for sharing. I'm glad it worked out great for you. :)

  4. Thank you very much Sepero, this script works very well in Fedora 18, no more shutdowns while watching Youtube videos...

    Just want to add the simple instructions to run the script on boot as root in Fedora 18:

    Create rc.local:

    # touch /etc/rc.d/rc.local

    Make it executable:

    # chmod +x /etc/rc.d/rc.local

    Open rc.local and add the following text:


    /root/ 98

    Change the last line with your path to the script and desired temperature, and don't forget to make the script executable too.

    Check if rc-local.service is running:

    # systemctl status rc-local.service

    Reboot and check if all went well by running again the above command, if all went well you should see something like this:

    # systemctl status rc-local.service
    rc-local.service - /etc/rc.d/rc.local Compatibility
    Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static)
    Active: activating (start) since Seg 2001-01-01 06:46:14 WET; 12 years 3 months ago
    Control: 1003 (rc.local)
    CGroup: name=systemd:/system/rc-local.service
    ├─ 1003 /bin/bash /etc/rc.d/rc.local start
    ├─ 1023 /bin/bash /root/ 98
    └─25269 sleep 3

  5. Great command. You can also use accurate temperature measurement devices and see how they work.

  6. Works great on Ubuntu 12.10. Thanks!

  7. I`ve got an error:

    $ sh 80 23: Syntax error: "(" unexpected
    ipeacocks@homepc:~/Downloads/cpu/temp-throttle-master$ bash 80
    Author: Sepero (sepero 111 @ gmail . com)
    Remote Python developer and Linux administrator for hire.

    Number of CPU cores detected: 4

    cat: /sys/class/thermal/thermal_zone0/temp: No such file or directory line 105: [: -gt: unary operator expected line 107: [: -le: unary operator expected

    1. Hi Ipeacocks, it doesn't run because you weren't using bash shell. I have made an update to the script so that it should now run with busybox shell also. Hopefully that helps. Cheers.

  8. This is fantastic. My ASUS laptop temp was breaking 80c running WINE, and now it doesn't top 65. When under load it stills runs a good 5-10c hotter than Windows 7, but it's much improved over the 10-20c difference I was seeing previously, both idling and under load. Thank you so much for this script!

  9. This is great!.. My HP laptop was always shutting down due to overheating. Now its stays below 80c often running at 75c while it usually run at 95-103c

  10. Hi Sepero I'm new in this, I run the script but I,ve git this error

    noelie@noelie-Aspire-5315:/tmp/temp-throttle-master$ sh 80
    Author: Sepero 2013 (sepero 111 @ gmx . com)

    -e Number of CPU cores detected: 1

    Error: Could not determine available cpu frequencies

    1. @madrisieraa, You have a technical problem that cannot be easily answered in the comment section of a blog. For further help, please contact me via email or on post an issue on Thank you

  11. Nice script. Very instructive. Actually took it only as a blueprint to throttle my CPU to a fixed max frequency. I have a Gaming Laptop with aggressive fan control. Throttling the CPU keeps the fan from speeding up during load peaks making it much more suitable for work related tasks (being still fast enough).

  12. Finally I fixed my laptop overheating problem with your script. I already was thinking of switching to windows. There are a lot of people struggling with overheating issue, just google "overheating linux" and you will see how many result will get back. We most share this script with the people who are struggling with this issue. THANKS ALOT Sepero