linux 下如何获取 cpu 温度

直接读取系统信息

可以通过读取如下路径中的数据来获取cpu的温度信息,不过读取的数据没有经过处理。

cpu0:
cat /sys/class/thermal/thermal_zone0/temp
cpu1:
cat /sys/class/thermal/thermal_zone1/temp

通过命令行的方式获取

  • 安装 lm_sensors 软件包:
# rpm
yum install lm_sensors

# deb
apt-get install lm-sensors
  • 执行命令sensors-detect,进行简单配置,此命令执行后会出现一系列选项,一直yes即可;

  • 执行命令sensors,查看cpu的温度。





原文地址:https://www.cnblogs.com/chuckzhang/p/a067ec85c5037a6d03a56fb443e88494.html