46

I would like to view the current fan speeds of my MacBook and iMac using terminal. I've found that running spindump then cat /tmp/spindump.txt | grep "Fan speed" will show it, but that's very slow and processor intensive. I would like a faster and more efficient way of doing it.

I'd rather not install 3rd party software, but I will if it's the only way.

Does anyone have any suggestions to how I might accomplish this?

Thanks

Joseph
  • 1,201

7 Answers7

36

On Mojave, spindump doesn't seem to list the fan speed. Noticed that powermetrics does, though. Try running sudo powermetrics -i 200 --samplers smc | grep Fan instead.

  • I just tried, but didn't get any output regarding fan speed, also the man page doesn't indicate anything. How exactly does this work on your Mac? – nohillside May 07 '19 at 10:28
  • 1
    powermetrics does take a few seconds to generate the fan speed, so let it run until it samples the SMC. In the man page for powermetrics on 10.14.4, I see the following under the Output description section: "SMC: The smc sampler displays information supplied by the System Management Controller. On supported platforms, this includes fan speed and information from various temperature sensors." My system is a 2018 MacBookPro15,1. – Supersheep May 12 '19 at 05:13
  • Ah, for whatever reason it fails to read SMC values on my Mac Mini (unable to get smc values). – nohillside May 12 '19 at 09:09
  • 4
    sudo powermetrics -i 1 -n 1 --samplers smc for a faster result. By default, powermetrics has a 5 second delay/interval. – wisbucky Jun 05 '20 at 00:59
  • This worked for me on a MacBookPro11,5 running Yosemite, as well. Got fan speed, as well as temperatures for both CPU and GPU. – lindes Jun 30 '20 at 08:10
  • "unable to get smc values" on MacBookPro9,2 running 10.14.6. – John Smith Nov 20 '20 at 23:14
27

smcFanControl

You mention in your comments having smcFanControl installed; this open source project includes the command line tool smc. You can use smc to get fan speed information via Terminal.app:

smc -f

See the smc manual page for more options.

Since Mac OS X 10.5, you need to use a third party piece of software to access the fan speed information. It appears no tool, installed by default on OS X, exposes this information through the terminal.

The open source project Fan Control includes a command line tool that provides fan speed information. This article, OS X: Current CPU temperature on command line, talks about the project and how to extract the fan speed:

smc -k TC0D -r | sed 's/.*bytes \(.*\))/\1/' |sed 's/\([0-9a-fA-F]*\)/0x\1/g' | perl -ne 'chomp; ($low,$high) = split(/ /); print (((hex($low)*256)+hex($high))/4/64); print "C\n";'

Avoid spindump

spindump requires administrator privileges and when run manually, spindump samples user and kernel stacks for every process in the system. This is a computationally expensive process, even when run for one second.

Alternatives

Other tools and applications exist, including Temperature Monitor. See Can I get the CPU temperature and fan speed from the command line in OS X?

Pre-Mac OS X 10.5

This article, get sensor information, shows how to use ioreg to extract the fan speed information with:

ioreg -c IOHWSensor | grep -B3 -A11 '"type" = "fanspeed"'

The above article and the script it contains was designed for Mac OS X 10.4.3.

See also:

Graham Miln
  • 43,776
  • 1
    Bresink's Temperature Monitor (which I use) is free for reading temperature, but needs a license to read other sensors (e.g. fan speed). – Gilby Jan 21 '14 at 21:33
  • It is good, but works only via command line, to find application go to: cd /Applications/smcFanControl.app/Contents/Resources/ – dr.dimitru May 22 '15 at 17:07
  • 3
    brew install Caskroom/cask/smcfancontrol and using it also requires password. – Nakilon Aug 21 '15 at 16:45
8

Oneliner - gives output after 1 second using spindump

SD=~/.spindump.txt;sudo rm $SD;sudo spindump 1 1 -file "$SD" ;grep "Fan speed" $SD

Each seperate part explained:

SD=~/.spindump.txt: create a variable with the .spindump.txt log

sudo rm $SD: clean up your tmp file using sudo rights, as the file was created by sudo spindump.

sudo spindump 1 1 -file $SD: run spindump as root (it only runs as root) for 1 second in 1 interval and output the file to your $SD

grep "Fan speed" $SD: get the line that says "Fan speed"

It is very unfortunate that we need sudo rights to run this script.


> SD=~/.spindump.txt;sudo rm $SD;sudo spindump 1 1 -file "$SD" ;grep "Fan speed" $SD

Password:
Sampling all processes for 1 seconds with 10 milliseconds of run time between samples
Focusing on launchd [1]
Sampling completed, processing symbols...
Spindump analysis written to file /Users/CousinCocaine/.spindump.txt
Fan speed:       2302 rpm
CousinCocaine
  • 10,098
6

Try sudo powermetrics -s smc. To change the refresh rate, use sudo powermetrics -s smc -i <milliseconds>.

2

Use the powermetrics built-in tool, asking for a single sample (-i 1 -n 1) for a fast answer.

$ sudo powermetrics -i 1 -n 1 --samplers smc | grep ^Fan
Fan: 2987 rpm
dolmen
  • 151
  • 3
0

I've got a MBA with SMC problems and this app solve my issue. The smcFanControl doesn't work for me and I've tryed FanControl too. In GNU/Linux I can set the max and min values thru terminal so if I can in GNU/Linux, I have to do the same in a Unix system. This app is Macs Fan Control https://github.com/crystalidea/macs-fan-control/releases/download/v1.4.12/macsfancontrol.zip

I hope work for you too

-5

Triple click the following, copy it, and paste it into Terminal:

sudo spindump 1 1 -file /tmp/spindump.txt > /dev/null 2>&1;grep "Fan speed" /tmp/spindump.txt;sudo rm /tmp/spindump.txt

It should output the fan speed.

Greg
  • 1
  • 4
    In the question, he says he does not want to do this exact thing. – Spotlight Aug 15 '15 at 15:12
  • 3
    Plus the question was answered fully last year. – Joseph Aug 16 '15 at 15:43
  • I'd like to add my voice to @Spotlight's. – D A Vincent Oct 19 '16 at 10:26
  • 4
    @Greg - Welcome to Ask Different. The community can seem be a bit brutal here at times which may be a bit off putting for new users such as yourself. I applaud your effort to contribute and wanted to point you toward our Help Center: How to Answer as a resource for writing answers which will attract views and up votes. Don't let the negative votes on your first answer dissuade you from contributing in the future. – Allan Aug 16 '18 at 14:22