Shell-WEB目录监控
Posted 李兴利
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Shell-WEB目录监控相关的知识,希望对你有一定的参考价值。
#!/bin/sh #date:2015-12-08 #filename:check_webfile.sh #作者:李兴利 #Email:[email protected] #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" [email protected] else echo "webfile OK" fi [[email protected] scripts]# rm -f /var/html/www/6629 [[email protected] 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 [email protected] ++ 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‘ [[email protected] scripts]# touch /var/html/www/6629 [[email protected] scripts]# vi /var/html/www/6629 fdfa 保存退出 [[email protected] 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 [email protected] ++ 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‘
更多内容请访问 李兴利博客
以上是关于Shell-WEB目录监控的主要内容,如果未能解决你的问题,请参考以下文章