定期刪除伺服器日誌
#判斷輸入的目錄是否存在
if (test -d $logfilepath)
then
cd $logfilepath
else
echo "輸入的日誌檔案目錄($logfilepath)不存在"
echo "注意:刪除失敗,已經退出!"
exit
fi
logdate=7
#刪除日誌檔案
echo "正在刪除$logdate天前的日誌檔案... ..."
find -atime +$logdate -name "commrhdle.*" -exec rm -f {} \;
find -atime +$logdate -name "commrrecv.*" -exec rm -f {} \;
find -atime +$logdate -name "commshdle.*" -exec rm -f {} \;
find -atime +$logdate -name "commssend.*" -exec rm -f {} \;
find -atime +$logdate -name "rltmrhdle.*" -exec rm -f {} \;
find -atime +$logdate -name "rltmrrecv.*" -exec rm -f {} \;
find -atime +$logdate -name "rltmshdle.*" -exec rm -f {} \;
find -atime +$logdate -name "rltmssend.*" -exec rm -f {} \;
find -atime +$logdate -name "simrbhdle.*" -exec rm -f {} \;
find -atime +$logdate -name "watchctl.*" -exec rm -f {} \;
cd $logfilepath/cicslog
find -atime +$logdate -exec rm -f {} \;
echo "刪除$logdate天前的日誌檔案成功!"