买了树莓派为了防止板子温度过高,想写个开机自启程序,当CPU温度超过85℃时自动关机
2条回答 默认 最新
- 战在春秋 2017-02-01 08:33关注
在论坛上找到一个范例,希望有帮助:
#!/bin/sh # This script reads the Broadcom SoC temperature value and shuts down if it # exceeds a particular value. # 80ºC is the maximum allowed for a Raspberry Pi. # Get the reading from the sensor and strip the non-number parts SENSOR="`/opt/vc/bin/vcgencmd measure_temp | cut -d "=" -f2 | cut -d "'" -f1`" # -gt only deals with whole numbers, so round it. TEMP="`/usr/bin/printf "%.0f\n" ${SENSOR}`" # How hot will we allow the SoC to get? MAX="78" if [ "${TEMP}" -gt "${MAX}" ] ; then # This will be mailed to root if called from cron echo "${TEMP}ºC is too hot!" # Send a message to syslog /usr/bin/logger "Shutting down due to SoC temp ${TEMP}." # Halt the box /sbin/shutdown -h now else exit 0 fi
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 thinkphp6配合social login单点登录问题
- ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
- ¥15 如何在scanpy上做差异基因和通路富集?
- ¥20 关于#硬件工程#的问题,请各位专家解答!
- ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
- ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
- ¥30 截图中的mathematics程序转换成matlab
- ¥15 动力学代码报错,维度不匹配
- ¥15 Power query添加列问题
- ¥50 Kubernetes&Fission&Eleasticsearch