Created
September 26, 2017 10:56
-
-
Save masterzorag/daaae47bcf7d32e6ebcca78faa430926 to your computer and use it in GitHub Desktop.
A simple bash script to get/set thermal cooling policy for each cpu
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 | |
# For all cpus, just report current states if no argument is passed | |
NCPU=$((`grep -c '^processor' /proc/cpuinfo`)) | |
if [ $# -lt 1 ]; | |
then | |
MAX=$((`cat /sys/devices/virtual/thermal/cooling_device0/max_state`)) | |
echo "Current cooling policy for $NCPU cpus: [0-$MAX]" | |
for (( i=0; i<$NCPU; i++ )) | |
do | |
cat /sys/devices/virtual/thermal/cooling_device$i/cur_state | |
done | |
exit | |
fi | |
# A first argument will update current states | |
echo "Setting cooling policy to $1 for $NCPU cpus" | |
for (( i=0; i<$NCPU; i++ )) | |
do | |
echo "Setting cpu $i" | |
echo "$1" > /sys/devices/virtual/thermal/cooling_device$i/cur_state | |
done | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment