Skip to content

Instantly share code, notes, and snippets.

@albarki
Forked from fduran/gist:1870429
Last active June 25, 2018 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save albarki/7e5c4c3ce98ef5d08524ac1acfd9ed78 to your computer and use it in GitHub Desktop.
Save albarki/7e5c4c3ce98ef5d08524ac1acfd9ed78 to your computer and use it in GitHub Desktop.
Linux disk space email alert
#!/bin/bash
# www.fduran.com
# script that will send an email to EMAIL when disk use in partition PART is bigger than %MAX
# adapt these 3 parameters to your case
MAX=95
EMAIL=alertemail@example.com,alteremail2@example.com
PART=sda1
USE=`df -h |grep $PART | awk '{ print $5 }' | cut -d'%' -f1`
if [ $USE -gt $MAX ]; then
echo "Percent used: $USE" | mail -s "Running out of disk space" $EMAIL
fi
@albarki
Copy link
Author

albarki commented Jun 25, 2018

to install mail if it is not exist check here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment