Linux CPU Frequency at Command Line
Monday, 3. May 2010
If you’d like to determine your CPUs’ frequencies at the command line, simply run this (sudo included):
sudo bash -c 'for i in `find /sys/devices/system/cpu/ -regextype posix-extended -iname "cpu[0-9]*"`; do echo -n `basename $i` ": "; cat $i/cpufreq/cpuinfo_cur_freq; done;'
If instead you’d like a continuous display, try this:
sudo bash -c '(while [[ -f /tmp/adf ]]; do clear; for i in `find /sys/devices/system/cpu/ -regextype posix-extended -iname "cpu[0-9]*"`; do echo -n `basename $i` ": "; cat $i/cpufreq/cpuinfo_cur_freq; done; sleep 1; done)'
The above code shows an example of controlling a while loop with the existence of a file. For the while loop to run at all, the file must be created (touch /tmp/adf); to stop the loop, the file need simply be removed (rm /tmp/adf).