dylan
11/14/2017 - 3:00 PM

Linux script to check if your hard disk is nearly full

Linux script to check if your hard disk is nearly full

#!/bin/bash

#start editing
mail="user@mail.com"
partition="/dev/sda1"
threshold="90"
#stop editing

percent=$(df -h | grep "$partition" | awk '{ print $5 }' | sed 's/%//g')
if ((percent > threshold))
then
echo "$partition at $(hostname -f) is nearly full" | mail -s "Your disk is nearly full!!!" "$mail"
fi