Low disk space alert bash script

Linux command

========================

cd /home/

vi disk_space_alert.sh

write into this bash script as follows

=========================

#!/bin/bash
#Define Variable
LIMIT='90'
DOMAIN=$(hostname)
DIR='/var/www'
MAILTO='hanamitsu_makoto@number-1.co.jp,saiful_takeshi@number-1.co.jp'
SUBJECT="Disk Usage Alert[$DOMAIN]"
#Command section
cd $DIR
USED=`df . |awk '{print $5}' | sed -ne 2p | cut -d"%" -f1`
DIRLIST=`du -sh ${DIR}/*`
if[ $USED -gt $LIMIT ]
then
 mail -s "$SUBJECT" $MAILTO <<EOF
 Hostname: $DOMAIN
 Your current used disk space is: $USED%
 Directory:${DIR}/*
 Details:
 $DIRLIST
DateTime: $(date)
EOF
fi

==========================

save file commadn

===========

😡

make the file as executable

========================

chmod +x disk_space_alert.sh

run this file

============

sh disk_space_alert.sh

 

 

corntab file

==============

#毎日10時00分に実行する
#ユーザー:root
00 10 * * * root /home/disk_space_alert.sh

 

zip file download 

 


Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 1052672 bytes) in /home/r8424051/public_html/nibatech.com/wiki/wp-includes/wp-db.php on line 1890