Last active
August 29, 2015 14:05
-
-
Save blackpioter/8384a9ff6c44dcb3fc38 to your computer and use it in GitHub Desktop.
tempcheck on raspberry pi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# vi /usr/bin/tempcheck | |
# */5 * * * * /usr/bin/tempcheck | |
# chmod 744 /usr/bin/tempcheck | |
#!/bin/sh | |
# This script reads the Broadcom SoC temperature value and shuts down if it | |
# exceeds a particular value. | |
# 80oC 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`" | |
#echo $SENSOR | |
# -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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment