可以使用sensors命令查看温度
先安装sensors,可以在Ubuntu、Debian、CentOS等系统上使用以下命令安装。
- Ubuntu、Debian系统:sudo apt install lm-sensors
- CentOS系统:sudo yum install lm_sensors
安装完后,如下debian例子所示:
root@pve2:~# apt install lm-sensors
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libsensors-config libsensors5
Suggested packages:
fancontrol read-edid i2c-tools
The following NEW packages will be installed:
libsensors-config libsensors5 lm-sensors
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 146 kB of archives.
After this operation, 518 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main amd64 libsensors-config all 1:3.6.0-7.1 [14.3 kB]
Get:2 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main amd64 libsensors5 amd64 1:3.6.0-7.1 [34.2 kB]
Get:3 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main amd64 lm-sensors amd64 1:3.6.0-7.1 [97.2 kB]
Fetched 146 kB in 0s (303 kB/s)
Selecting previously unselected package libsensors-config.
(Reading database ... 45157 files and directories currently installed.)
Preparing to unpack .../libsensors-config_1%3a3.6.0-7.1_all.deb ...
Unpacking libsensors-config (1:3.6.0-7.1) ...
Selecting previously unselected package libsensors5:amd64.
Preparing to unpack .../libsensors5_1%3a3.6.0-7.1_amd64.deb ...
Unpacking libsensors5:amd64 (1:3.6.0-7.1) ...
Selecting previously unselected package lm-sensors.
Preparing to unpack .../lm-sensors_1%3a3.6.0-7.1_amd64.deb ...
Unpacking lm-sensors (1:3.6.0-7.1) ...
Setting up libsensors-config (1:3.6.0-7.1) ...
Setting up libsensors5:amd64 (1:3.6.0-7.1) ...
Setting up lm-sensors (1:3.6.0-7.1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/lm-sensors.service → /lib/systemd/system/lm-sensors.service.
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for libc-bin (2.36-9+deb12u1) ...
运行sensors命令即可查看系统CPU温度
root@pve2:~# sensors
power_meter-acpi-0
Adapter: ACPI interface
power1: 4.29 MW (interval = 1.00 s)
pch_skylake-virtual-0
Adapter: Virtual device
temp1: +31.5°C
acpitz-acpi-0
Adapter: ACPI interface
temp1: +27.8°C (crit = +119.0°C)
temp2: +29.8°C (crit = +119.0°C)
coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +28.0°C (high = +80.0°C, crit = +100.0°C)
Core 0: +27.0°C (high = +80.0°C, crit = +100.0°C)
Core 1: +28.0°C (high = +80.0°C, crit = +100.0°C)
Core 2: +27.0°C (high = +80.0°C, crit = +100.0°C)
Core 3: +26.0°C (high = +80.0°C, crit = +100.0°C)
nvme-pci-0100
Adapter: PCI adapter
Composite: +33.9°C (low = -273.1°C, high = +84.8°C)
(crit = +84.8°C)
Sensor 1: +33.9°C (low = -273.1°C, high = +65261.8°C)
Sensor 2: +31.9°C (low = -273.1°C, high = +65261.8°C)
也可以使用cat命令查看:
使用如下命令可以查看CPU的温度:
```
cat /sys/class/thermal/thermal_zone*/temp
```
其中/sys/class/thermal/thermal_zone* 目录下的 thermal_zone* 就是CPU各个核心对应的监测点。每个文件中的数字为千分之一度,即需要除以1000才是实际的摄氏度。比如对于文件/sys/class/thermal/thermal_zone0/temp,其实际温度就是:
```
cat /sys/class/thermal/thermal_zone0/temp | awk '{printf "%.2f°C", $1/1000}'
```
这两种方法都需要root权限