fang-d

一个命令搞定:

cat /sys/class/thermal/thermal_zone0/temp

输出的结果除以1000即为当前环境温度(单位为摄氏度)。
另附一个检测CPU温度,过高自动关机的C++程序:

#include <iostream>
#include <fstream>

using namespace std;

int main(void)
{
	ifstream file("/sys/class/thermal/thermal_zone0/temp", ios::in);
	int temp = 0;
	file >> temp;
	file.close();
	if (temp > 65000)
	{
		system("`date` > /root/shutdown_time.log");
		system("shutdown now");
	}
	else
	{
		cout << temp << endl;
	}
	return 0;
}

分类:

技术点:

相关文章:

  • 2021-12-24
  • 2021-05-28
  • 2022-02-25
  • 2022-02-26
  • 2021-12-29
  • 2022-12-23
  • 2021-12-13
  • 2022-02-06
猜你喜欢
  • 2022-02-19
  • 2022-02-23
  • 2022-03-01
  • 2022-01-29
  • 2022-02-10
  • 2021-07-24
相关资源
相似解决方案