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 ./temp_throttle.sh 80
This can also result in longer battery life on laptops and portable devices.
Note: This script may not be effective if your system over heating is primarily due to factors other than your CPU. This script simply throttles your CPU frequency based on your systems reported temperature.
Click here to download this temperature throttling script for Linux. Please direct links to this page and the download location will remain up to date.
New User Resources:
Download: temperature throttling script - temp_throttle.sh
https://github.com/Sepero/temp-throttle
If this script helps you in any way, please pay me with a message of thanks, and share this page with others. If you have better ideas or suggestions, then contact me in the comments or email sepero 111 @ gmail.com
Keywords:
cpu scaling temperature control Linux
Hi, nice script! umm, my /sys/class/hwmon/hwmon0/temp1_input
ReplyDeletealways 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.
thx!
Thanks for the info, Willem. I've updated the code to hopefully accommodate more people.
DeleteFinally! I've found you!
ReplyDeleteI published your script at http://forum.rosalab.ru/viewtopic.php?f=39&t=1645 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 :) )
Hi Russian friend, thank you for sharing. I'm glad it worked out great for you. :)
ReplyDeleteThank you very much Sepero, this script works very well in Fedora 18, no more shutdowns while watching Youtube videos...
ReplyDeleteJust 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:
#!/bin/bash
/root/temp_throttle.sh 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/temp_throttle.sh 98
└─25269 sleep 3
Great command. You can also use accurate temperature measurement devices and see how they work.
ReplyDelete