Skip to content

Instantly share code, notes, and snippets.

@masterzorag
Created September 26, 2017 10:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masterzorag/daaae47bcf7d32e6ebcca78faa430926 to your computer and use it in GitHub Desktop.
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
#!/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