Payament
Free Photos
WordPress Themes

Send an Email Alert When Your Disk Space Gets Low

#!/bin/bash # Send an Email Alert When Your Disk Space Gets Low # The script sends an email when the disk usage rises above the percentage specified by the MAX varialbe (80% here). # adapt these 3 parameters to your case # To run it daily, for example, save the script to the file sample.sh in your home directory, change the email to your email, and add the following line at the end of /etc/crontab file: # @daily ~/sample.sh MAX=80 EMAIL=alert@mail.com PART=/ 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

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.