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

5

7 Answers 7

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:

3
  • 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, 2014 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, 2015 at 17:07
  • 3
    brew install Caskroom/cask/smcfancontrol and using it also requires password.
    – Nakilon
    Aug 21, 2015 at 16:45
35

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.

6
  • 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 7, 2019 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, 2019 at 5:13
  • Ah, for whatever reason it fails to read SMC values on my Mac Mini (unable to get smc values).
    – nohillside
    May 12, 2019 at 9: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 5, 2020 at 0: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, 2020 at 8:10
7

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
10
  • I'm running 10.8.5 on an iMac and my spindump report doesn't include any mention of "Fan speed" or even "fan".
    – aaaidan
    Jan 22, 2014 at 1:44
  • I am running 10.9.1. I cannot find my 'version' of spindump, but my fan speed is in the first 20 lines. Jan 22, 2014 at 7:54
  • are you on a laptop or desktop?
    – aaaidan
    Jan 22, 2014 at 22:13
  • @aaaidan I am running a Mac Mini (Hardware model: Macmini5,3) and an MBP retina (Hardware model: MacBookPro11,1). Both have the variable "Fan speed" in their output. Jan 23, 2014 at 13:44
  • 1
    Not finding this reliable. on my Macbook I have to take out the Touch part for it to work but then the rm does not work. Also if I run: sudo spindump 1 1 -file /tmp/spindump.txt > /dev/null 2>&1;grep "Fan speed" /tmp/spindump.txt One try it works next try it does not
    – markhunte
    Jan 23, 2014 at 14:28
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
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.

4
  • 4
    In the question, he says he does not want to do this exact thing.
    – Spotlight
    Aug 15, 2015 at 15:12
  • 3
    Plus the question was answered fully last year.
    – Joseph
    Aug 16, 2015 at 15:43
  • I'd like to add my voice to @Spotlight's. Oct 19, 2016 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, 2018 at 14:22

Not the answer you're looking for? Browse other questions tagged .