nacos清理日志脚本

#!/bin/sh

############################
#$1 nacos home
#$2 log save days
#############################

logs_path=$1
savedays=$2

echo $(date)-----------------clean >> ./nacosClean.log
#清理logs文件夹下的access.log文件
delList=$(find $logs_path/logs/ -mtime +$savedays -name "access_log.*.log")
#echo $delList >> ./nacosClean.log
for i in $delList
 do
   rm -rf $i
   echo $i>>./nacosClean.log
 done
 
#清理bin文件夹下的access.log文件
delList=$(find $logs_path/bin/logs/ -mtime +$savedays -name "access_log.*.log")
#echo $delList >> ./nacosClean.log
for i in $delList
 do
   rm -rf $i
   echo $i>>./nacosClean.log
 done
 
#清理logs文件夹下的其它文件
delList=$(find $logs_path/logs/ -mtime +$savedays -name "*.log.*")
#echo $delList >> ./nacosClean.log
for i in $delList
 do
   rm -rf $i
   echo $i>>./nacosClean.log
 done
 
posted @ 2023-10-17 18:43  GaoYanbing  阅读(306)  评论(0编辑  收藏  举报