如何禁用热关断

如何禁用热关断

我并不是想完全禁用热保护,而是想让 Ubuntu 12.04 进入睡眠或休眠状态,而不是立即关闭机器。作为一名程序员,我的 IDE 和项目在关闭不当时会崩溃。

当达到热峰值时,有没有解决方案可以休眠或睡眠?

更新:

我的笔记本电脑不会在随机时间热关机,它会在编译(Java 应用程序)、CPU 使用率达到最大值时关机,在浏览互联网时也无问题,所以问题出在硬件上。它不会每次都发生,我只是希望当它发生时它会休眠或睡眠。

答案1

经过很长一段时间我才找到答案:

#!/bin/bash

# PURPOSE: Script to check temperature of CPU cores and report/shutdown if specified temperatures exceeded
#
# AUTHOR: feedback[AT]HaveTheKnowHow[DOT]com

# Expects two arguments:
# 1. Warning temperature
# 2. Critical shutdown temperature
# eg. using ./CPUTempShutdown.sh 30 40
# will warn when temperature of one or more cores hit 30degrees and shutdown when either hits 40degrees.

# NOTES:
# Change the strings ">>/home/xybrek" as required
# Substitute string "[email protected]" with your own email address in the string which starts "/usr/sbin/ssmtp [email protected]"

# Assumes output from sensors command is as follows:
#
# coretemp-isa-0000
# Adapter: ISA adapter
# Core 0: +35.0 C (high = +78.0 C, crit = +100.0 C) 
#
# coretemp-isa-0001
# Adapter: ISA adapter
# Core 1: +35.0 C (high = +78.0 C, crit = +100.0 C) 
#
# if not then modify the commands str=$(sensors | grep "Core $i:") & newstr=${str:14:2} below accordingly

echo "JOB RUN AT $(date)"
echo "======================================="

echo ''
echo 'CPU Warning Limit set to => '$1
echo 'CPU Shutdown Limit set to => '$2
echo ''
echo ''

sensors

echo ''
echo ''
stop=0
while true;
do
sleep 1.5
for i in 0 1
do
str=$(sensors | grep "Core $i:")
newstr=${str:17:2}

if [[ ${newstr} -ge $1 ]]
then
echo '============================' >>/home/xybrek/Desktop/CPUWarning.Log
echo $(date) >>/home/xybrek/Desktop/CPUWarning.Log
echo '' >>/home/xybrek/Desktop/CPUWarning.Log
echo ' WARNING: TEMPERATURE CORE' $i 'EXCEEDED' $1 '=>' $newstr >>/home/xybrek/Desktop/CPUWarning.Log
echo '' >>/home/xybrek/Desktop/CPUWarning.Log
echo '============================' >>/home/xybrek/Desktop/CPUWarning.Log
fi

if [[ ${newstr} -ge $2 ]]
then
echo '============================'
echo ''
echo 'CRITICAL: TEMPERATURE CORE' $i 'EXCEEDED' $2 '=>' $newstr
echo ''
echo '============================'
sudo pm-suspend
echo 'Sleeping....'
#exit
else
echo ' Temperature Core '$i' OK at =>' $newstr
echo ''
fi
done
done

echo 'Both CPU Cores are within limits'
echo ''

相关内容