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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章