check drive space script for linux

#!/bin/bash
CURRENT=$(df /usr/local/inmsf | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=85

if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
mail -s 'Disk Space Alert for inmon4.vpls.net' [email protected] << EOF Your root partition remaining free space is critically low. Used: $CURRENT% EOF fi CURRENT=$(df /archive | grep / | awk '{ print $5}' | sed 's/%//g') THRESHOLD=85 if [ "$CURRENT" -gt "$THRESHOLD" ] ; then mail -s 'Disk Space Alert for inmon4.vpls.net' [email protected] << EOF Your root partition remaining free space is critically low. Used: $CURRENT% EOF fi

sometimes have to modify print $5 to $4 depending on the column. Also change the partition you want to monitor.

df /usr/local/inmsf | grep / | awk '{ print $5}' | sed 's/%//g'

add to crontab

0 0 * * * root bash /root/drivespace.sh &>/dev/null

Leave a Reply