nacos清理日志脚本

nacos在bin和logs目录下都会写日志,时间长了日志文件会比较大,写了个脚本定时清理

#!/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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容