Created
May 21, 2013 08:10
-
-
Save sunix/5618251 to your computer and use it in GitHub Desktop.
This script change the CPU governor according to the temperature detected. Useful when your linux laptop is shutting down because the cpu is reaching 100°C. Script attached to:
CPU overheats during high usage "throttling <not supported>"
https://bugs.launchpad.net/bugs/22336
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
############################################################################### | |
# Copyright (C) 2005 Francois COJEAN | |
# Copyleft 2007 Sun Seng David TAN | |
# This program is free software; you can redistribute it and/or | |
# modify it under the terms of the GNU General Public License | |
# as published by the Free Software Foundation; either version 2 | |
# of the License, or (at your option) any later version. | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# You should have received a copy of the GNU General Public License | |
# along with this program; if not, write to the Free Software | |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
############################################################################### | |
# this script change the CPU governor according to the temperature detected. | |
# Note : this script need to be run as root. | |
# TODO : maybe use inotify | |
# Set up the different variables | |
# Edit all this variable to value which fit to your computer | |
POWERSAVE_SCALING_GOVERNOR="powersave" | |
CONSERVATIVE_SCALING_GOVERNOR="conservative" | |
ONDEMAND_SCALING_GOVERNOR="ondemand" | |
CPU_FREQ_PATH="/sys/devices/system/cpu/cpu0/cpufreq" | |
SCALING_GOVERNOR_FILE="scaling_governor" | |
TEMPERATURE_ACPI_PATH="/proc/acpi/thermal_zone/TZS0" | |
TEMPERATURE_MAX=87 | |
TEMPERATURE_SAFE=73 | |
while true; do | |
TEMPERATURE="`cat $TEMPERATURE_ACPI_PATH/temperature |cut -d' ' -f14`" | |
echo $TEMPERATURE | |
if [ $TEMPERATURE -gt $TEMPERATURE_MAX ] | |
then | |
echo "$POWERSAVE_SCALING_GOVERNOR" > $CPU_FREQ_PATH/$SCALING_GOVERNOR_FILE | |
echo "CPU_FREQ : $POWERSAVE_SCALING_GOVERNOR enable" | |
fi | |
if [ $TEMPERATURE -lt $TEMPERATURE_SAFE ] | |
then | |
echo "$ONDEMAND_SCALING_GOVERNOR" > $CPU_FREQ_PATH/$SCALING_GOVERNOR_FILE | |
echo "CPU_FREQ : $ONDEMAND_SCALING_GOVERNOR enable" | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment