HowTo Force/Change CPU Frequency in Linux

For Linux Systems you may find yourself need to change the CPU frequency in your cluster. Here is a simple script. 


Instructions

1. Check the current CPU speed

$ cd /sys/devices/system/cpu
$ cat ./cpu0/cpufreq/scaling_available_frequencies
 2001000 2000000 1900000 1800000 1700000 1600000 1500000 1400000 1300000 1200000 1100000 1000000

$ cat cpu0/cpufreq/scaling_max_freq
2001000
$ cat cpu0/cpufreq/scaling_min_freq
1000000


2. Create a similar script based on this script

cd /sys/devices/system/cpu

newSpeedTop=`awk '{print $4}' ./cpu0/cpufreq/scaling_available_frequencies` #change Helios Freq to 1800000 (1.8GHz) on all cores
newSpeedLow=$newSpeedTop  # make them the same in this example
for c in ./cpu[0-39]* ; do
    echo $newSpeedTop | sudo tee ${c}/cpufreq/scaling_max_freq
    echo $newSpeedLow | sudo tee ${c}/cpufreq/scaling_min_freq
done