[root@zyl web_scripts]# cat md5sum.sh #!/bin/sh #-------------------------------------------- #Author: Created by zhangyiling 2016-09 #Function: This scripts function is "Monitoring Web Site" #Version:4.1.2 #--------------------------------------------- LANG=en MD5_PATH=/server/scripts/web_scripts CAT_LOG=`cat $MD5_PATH/check_site.log` [ ! -f "$CAT_LOG" ] && touch $MD5_PATH/check_site.log while true do F=`md5sum -c $MD5_PATH/md5sum.db 2>/dev/null|grep FAILED|wc -l` find /application/nginx/html/bbs -type f >$MD5_PATH/new_site.log TMP_LOG=/tmp/check.log [ ! -f $TMP_LOG ] && touch $TMP_LOG if [ $F -ne 0 ] || [ `cat $MD5_PATH/new_site.log|wc -l` -ne `cat $CAT_LOG|wc -l` ];then echo "`md5sum -c md5sum.db 2>/dev/null|grep FAILED`" >$TMP_LOG diff $MD5_PATH/check_site.log $MD5_PATH/new_site.log >>$TMP_LOG 2>&1 mail -s "site is cuangai $(date)" 813415154@qq.com <$TMP_LOG fi sleep 180 done #也可写入定时任务:*/3 * * * * /bin/sh /server/scripts/web_scripts/md5sum.sh >/dev/null 2>&1
转载于:https://blog.51cto.com/zhagyilig/1852896