shell脚本***检测与邮件报警

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell脚本***检测与邮件报警相关的知识,希望对你有一定的参考价值。

#!/bin/bash
webdir=/var/www/html
cd $webdir
md5sum -c --quiet /opt/sumfile.db &>/opt/sum_err.log
if [ $? -ne 0 ]
then
echo "the file_sum is changed"
mail -s "sum_error" [email protected] </opt/sum_err.log
else
echo "check file_sum is ok"
fi

find /var/www/html/ -type f >/opt/countfile.dbsec
diff /opt/countfile.db
&>/opt/counterr.log
if [ $(diff /opt/countfile.db
|wc -l) -gt 0 ]
then
echo "the file_count is changed"
mail -s "count_err" [email protected] </opt/count_err.log
else
echo "check file_count is ok"
fi

以上是关于shell脚本***检测与邮件报警的主要内容,如果未能解决你的问题,请参考以下文章