标签:
#!/bin/sh #date:2015-12-08 #filename:check_webfile.sh #作者:李兴利 #Email:1162572407@qq.com #version:v1.1 webfile_path=/var/html/www/ file_num=`ls ${webfile_path}|wc -l` find ${webfile_path} -type f|xargs md5sum >>/server/check_webfile.db if [ `md5sum -c /server/check_webfile.db|grep -i fail|wc -l` -ne 0 ] || [ ${file_num} -ne 49 ] then echo "`md5sum -c /server/check_webfile.db|grep -i fail`"|mail -s "cuangai" 1729294227@qq.com else echo "webfile OK" fi [root@web02 scripts]# rm -f /var/html/www/6629 [root@web02 scripts]# sh -x check_webfile01.sh + webfile_path=/var/html/www/ ++ wc -l ++ ls /var/html/www/ + file_num=48 + xargs md5sum + find /var/html/www/ -type f ++ wc -l ++ grep -i fail ++ md5sum -c /server/check_webfile.db md5sum: /var/html/www/6629: No such file or directory md5sum: /var/html/www/6629: No such file or directory md5sum: /var/html/www/6629: No such file or directory md5sum: /var/html/www/6629: No such file or directory md5sum: WARNING: 4 of 292 listed files could not be read + ‘[‘ 4 -ne 0 ‘]‘ + mail -s cuangai 1729294227@qq.com ++ grep -i fail ++ md5sum -c /server/check_webfile.db md5sum: /var/html/www/6629: No such file or directory md5sum: /var/html/www/6629: No such file or directory md5sum: /var/html/www/6629: No such file or directory md5sum: /var/html/www/6629: No such file or directory md5sum: WARNING: 4 of 292 listed files could not be read + echo ‘/var/html/www/6629: FAILED open or read /var/html/www/6629: FAILED open or read /var/html/www/6629: FAILED open or read /var/html/www/6629: FAILED open or read‘ [root@web02 scripts]# touch /var/html/www/6629 [root@web02 scripts]# vi /var/html/www/6629 fdfa 保存退出 [root@web02 scripts]# sh -x check_webfile01.sh + webfile_path=/var/html/www/ ++ wc -l ++ ls /var/html/www/ + file_num=49 + xargs md5sum + find /var/html/www/ -type f ++ wc -l ++ grep -i fail ++ md5sum -c /server/check_webfile.db md5sum: WARNING: 4 of 341 computed checksums did NOT match + ‘[‘ 4 -ne 0 ‘]‘ + mail -s cuangai 1729294227@qq.com ++ grep -i fail ++ md5sum -c /server/check_webfile.db md5sum: WARNING: 4 of 341 computed checksums did NOT match + echo ‘/var/html/www/6629: FAILED /var/html/www/6629: FAILED /var/html/www/6629: FAILED /var/html/www/6629: FAILED‘
更多内容请访问 李兴利博客
标签:
原文地址:http://www.cnblogs.com/lixingli/p/5539030.html