1. The script content is as follows
#!/bin/bash
#获取校验库,只需要在首次执行的时候获取!
#file=$(find /var/www/html/ -type f)
#echo > md5.txt
#for i in $file
#do
# md5sum $i >> md5.txt
#done
#通过检查校验库文件的MD5值,有更改时发送邮件通知
md5sum -c md5.txt
if [ $? -ne 0 ];then
echo "有更改"
message=$(md5sum -c md5.txt|grep "FAILED")
mail.py [email protected] "警告" "$message"
fi
2. Modify the /var/www/html/index.php file and execute the script
[root@host-134 ~]# sh check_md5.sh