tomcat日志清理,压缩

#!/bin/bash
tomcatRoot=/data/server/tomcats
for tomcatDir in `ls $tomcatRoot`
 do
   logDir="$tomcatRoot/$tomcatDir/logs"
     find $logDir -type f -name "app*20??-??-??.log" -mtime +7 -exec gzip {} \; > /dev/null 2>&1
     find $logDir -type f -name "catalina.20??-??-??.out" -mtime +7 -exec gzip {} \; > /dev/null 2>&1
     find $logDir -type f -name "localhost_access_log.20??-??-??.txt" -mtime +7 -exec gzip {} \; > /dev/null 2>&1
 done
#!/bin/bash
tomcatRoot=/data/server/tomcats
used=` df -h | grep "/d01" |awk -F'[ %]+' '{printf $5}'`
  for tomcatDir in `ls $tomcatRoot`
    do
    logDir="$tomcatRoot/$tomcatDir/logs"
     if [ $used -gt 50 ]
       then
         find  $logDir/* -type f -mtime +14 -exec rm -rf {} \; >/dev/null 2>&1
       else
      exit
     fi
    done

 

posted @ 2018-07-12 16:24  cornerxin  阅读(940)  评论(0编辑  收藏  举报