Monitor Hard Disk Temperature in Ubuntu/Debian

**Required Software**

 apt-get install smartmontools

Then, we’ll create a simple script.

 nano /root/scripts/

Paste this in…

 #! /bin/bash
DISKS="`blkid | grep sd | cut -c 1-8 | uniq`"
ARGS="-a -d ata"
for disk in $DISKS
 if [ -b $disk ]; then
 HDTEMP=$($SMART $ARGS $disk | grep -m 1 Temperature | awk '{print $10}')
 if [ $HDTEMP -ge $ALERT_LEVEL ]; then
 $LOG "System going down as hard disk : $disk temperature $HDTEMP°C crossed its limit"
 $DOWN -h 0

*Press ctrl+x, then y to save and quit nano* This script will find all hard drives connected via SATA, and if SMART monitoring is enabled on them, will check the temperature and shut the system down if it’s above the temperature threshold of 55°C. *Note: This script will not work as is with IDE disks, or disks in a hardware RAID array* Next, we need to make the script executable.

 chmod +x /root/scripts/

And add it to your root cronjob

 crontab -e

Your cron entry should look like this.

 */15 * * * * /root/scripts/

The above will set the script to run every 15 minutes.


I love learning new things and trying out the latest technology.

You may also like...

2 Responses

  1. kiwijunglist says:

    Doesn’t this script wake all the HDDs up every 15 minutes?

    Don’t you need to use -n standby or -n idle

    • Zack says:

      Yes, this script will wake up disks every 15 minutes without the standby option. As an FYI, I don’t bother with monitoring my hard drive temps with this script.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.