Setting the cpu governor to powersave on all cpus

Some of the time the ‘cpufreq-set’ command doesn’t work as expected and you need to run the command for every core on a system but if you have a lot of cores it gets tiring really fast.
The snippet bellow to run cpufreq-set once on every core of the system.

Create the file ‘/sbin/cpufreq-set-all’ with the following:


   #!/bin/bash
   MAX_CPU=$((`nproc --all` - 1))
   for i in $(seq 0 $MAX_CPU); do
       echo "Changing CPU " $i " with parameter "[email protected];
       cpufreq-set -c $i [email protected] ;
   done

 
Enable execution with:


chmod +x /sbin/cpufreq-set-all


 
Now all you need to do to change all cores to “powersave” run:


cpufreq-set-all -g powersave

 
And to go back to “on demand” mode run:


cpufreq-set-all -g performance

 
The snippet above was copied from an answer on askubuntu on the link below, be sure to visit the thread for more information or other implementations of the same fix.
 
If you want the changes to be permanent create or edit the ‘/etc/default/cpufrequtils’ file with the following:


# valid values usually are : powersave ondemand performance
# get a list for your system with 'cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors'
GOVERNOR="powersave"

 

Sources:

https://askubuntu.com/a/858391
https://wiki.debian.org/CpuFrequencyScaling