Skip to content

Instantly share code, notes, and snippets.

@discarn8
Created May 2, 2018 07:52
Show Gist options
  • Save discarn8/cdb8735fb97f7a075dd7a10165a7faa4 to your computer and use it in GitHub Desktop.
Save discarn8/cdb8735fb97f7a075dd7a10165a7faa4 to your computer and use it in GitHub Desktop.
hdd_temp_shutdown_with_log.sh
#!/bin/bash
HDDS="/dev/sda /dev/sdb /dev/sdc"
HDT=/usr/sbin/hddtemp
LOG=/usr/bin/logger
DOWN=/sbin/shutdown
ALERT_LEVEL=55
for disk in $HDDS
do
if [ -b $disk ]; then
HDTEMP=$($HDT $disk | awk '{ print $4}' | awk -F '°' '{ print $1}')
if [ $HDTEMP -ge $ALERT_LEVEL ]; then
$LOG "System going down as hard disk : $disk temperature $HDTEMP°C crossed its limit"
sync;sync
$DOWN -h 0
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment