#!/usr/bin/bash # Throttle all CPUs to $1 MHz. Requires cpufreqd and/or cpufrequtils # (not sure which). m=${1:-3000} echo "Try using top speed of ${m}MHz..." nCpu=$(/usr/bin/lscpu | /usr/bin/awk '/^CPU\(s\):/{print $2}') if [ x = "x${nCpu}" ]; then echo "Cannot determine CPU count" 1>&2 exit 1 fi i=0 set -e while [ $i -lt $nCpu ]; do sudo cpufreq-set -c $i -r -d 400MHz -u ${m}MHz echo "CPU${i}: ${m}MHz" i=$((i + 1)) # -r "should" set it for all CPUs at once but is not doing so # for me. Indeed, the man page says: On Linux kernels up to # 2.6.29, the -r or --related parameter is ignored. done