Skip to content

Instantly share code, notes, and snippets.

@haxwithaxe
Created May 11, 2025 16:31
Show Gist options
  • Save haxwithaxe/55663d1f9d6a3ecbb4bda0b6f090d2f0 to your computer and use it in GitHub Desktop.
Save haxwithaxe/55663d1f9d6a3ecbb4bda0b6f090d2f0 to your computer and use it in GitHub Desktop.
A script to quickly and dirtyly manually manage Xeon CPU governor settings.
#!/bin/bash
set_govs() {
local mode=$1
for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
echo $mode | sudo tee $i
done
}
get_govs() {
for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
cat $i
done
}
main() {
case $1 in
print|get|show)
get_govs
return
;;
s|sched|schedutil)
set_govs schedutil
return
;;
p|perf|performance)
set_govs performance
return
;;
save|power|powersave)
set_govs powersave
return
;;
u|user|userspace)
set_govs userspace
return
;;
o|d|demand|ondemand)
set_govs ondemand
return
;;
c|con|conservative)
set_govs conservative
return
;;
*)
echo $0 'schedutil|performance|powersave|userspace|ondemand|conservative'
echo 'https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt'
return
;;
esac
}
main $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment