Skip to content

Instantly share code, notes, and snippets.

@RCasatta
Created April 9, 2022 13:33
Show Gist options
  • Save RCasatta/c8a2f956288ff50d2e81ff4748dbde0e to your computer and use it in GitHub Desktop.
Save RCasatta/c8a2f956288ff50d2e81ff4748dbde0e to your computer and use it in GitHub Desktop.
Set the max frequency of the CPU
#!/bin/bash
# verify your available scaling frequency with:
# `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies`
# and adapt this script
unset FREQ
case $1 in
min)
FREQ=1400000
;;
med)
FREQ=1700000
;;
max)
FREQ=1800000
;;
status)
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
;;
*)
echo "Use cpufreq.sh min|med|max|status"
;;
esac
if ! [ -z ${FREQ+x} ]; then
for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq;
do sudo sh -c "echo $FREQ > $file;"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment