bash script to check left space on device
This is a very simple bash script intended to be used for checking the space on every partition from your hardisk #!/bin/bash PROG_NAME="space_usage" #Set usage USED_SPACE="95" #log file if you want to use log file LOG_FILE="space.txt" #email address EMAIL="user@localhost" SEND_EMAIL="N" #crontab every night at 12 #0 0 * * * root space.sh function log() { /usr/bin/logger -i -p kern.crit -t ${PROG_NAME} "UPSS: ${i[5]} has used more than $USED_SPACE % space" echo "UPSS: ${i[5]} has used more than $USED_SPACE % space" >> $LOG_FILE #send email if [ $SEND_EMAIL == 'Y' ] then mail -s "no more space on ${i[5]} " $EMAIL fi } #grep mounted partitions df -k -P --sync |grep -v "Mounted" | while read i; do i=( ${i} ) #echo mounted partitions #echo ${i[5]} USED=`df ${i[5]} | awk '{print $5}' |grep -v "Use%" | cut -f1 -d%` #...