The Linux Page

Watching the frequency of my CPUs in real time under Linux

CPU frequencies as I run one large compression.

I noticed that the Linux Kernel allows for CPU frequencies to vary. But I could not really see any CPU running at a speed other than 800MHz when looking at /proc/cpuinfo so I thought that they were "stuck" there.

Looking a little further, I found a question with a good answer on Unix & Linux. You can use /proc/cpuinfo alright, but you've got to look at it constantly otherwise it will not look like it changes. That is, the change is so temporary, it happens so fast, that you really have to track that quickly otherwise you'll miss it.

Here is a command we can readily use in our console:

watch -n.1 "grep '^[c]pu MHz' /proc/cpuinfo | column"

The command runs the following shell script 10 times per second (-n.1 means repeat every 0.1 seconds, or 10 times per second). Note that some older versions of watch do not support sub-seconds delays. In that case use -n1 instead or do not specify the -n option (the default is once every other second).

The script greps through the /proc/cpuinfo for the CPU MHz field and prints it out to the column tool which allows for showing the output in columns instead of one long list (which is important if you have 64+ processors like me).

I'm impressed by the speed at which the frequency changes. It's constantly changing. Often not by much, but at times it can vary by a good 1GHz. Also, I see some CPUs running at up to 3.2GHz when my CPUs are clearly marked as 2.1GHz Xeons. What's up with that?!