Apple - Can I get the CPU temperature and fan speed from the command line in OS X?

The iStats ruby gem lets you see the CPU temperature via the command-line.

Installation

$ gem install iStats

Usage

$ istats all

Screenshot


Option #1) you may consider using inbuilt utility powermetrics to get the cpu and gpu temperature and lot more other details.

To get CPU temperature:

sudo powermetrics --samplers smc |grep -i "CPU die temperature"

enter image description here

To get GPU temperature:

sudo powermetrics --samplers smc |grep -i "GPU die temperature"

To get lot more details:

sudo powermetrics

This has been tested on macbook pro with macOS mojave.

Option #2) Install Intel® Power Gadget officially provided by Intel from here

Intel® Power Gadget and then launch Intel Power Gadget from the launchpad.

enter image description here

Result Screen:

enter image description here


On BSD systems, the sysctl utility can provides similar information as the /proc tree in Linux. It actually report some CPU/GPU temperature information from Xnu CPU Power Management (XCPM):

sysctl machdep.xcpm.cpu_thermal_level
sysctl machdep.xcpm.gpu_thermal_level

However this doesn't seem to be a temperature reading but only an indication of the temperature level compared to some reference.