场景:日志量比较大,且研发程序没有设置分卷

 

1、配置样例:

文件路径:/etc/logrotate.d/tomcat

/data/logs/catalina.out {

        daily

        compress

        delaycompress

        copytruncate

        create 0644  root  root    #根据实际用户填写

        rotate 10                  #保留的个数和大小根据实际磁盘空间设置

        size  500M

}

 

加入定时任务

0 *  *  *  *   /usr/sbin/logrotate  /etc/logrotate.d/tomcat   2>&1 >>/dev/null

 

2、日志保留7天脚本:

#cat rmlog.sh

#!/bin/bash
dir1=/home/apache-tomcat-7.0.64/logs
find $dir1  -mtime +3  -name "*.2017*"  -exec rm -rf {} \;

#脚本日志文件路径根据实际情况修改。

加入定时任务:

0  1  *  *  *    /home/scripts/rmlog.sh  2>&1 >>/dev/null

相关文章:

  • 2021-12-10
  • 2018-01-17
  • 2022-12-23
  • 2021-11-04
  • 2021-07-20
  • 2021-10-21
  • 2021-10-05
  • 2022-02-16
猜你喜欢
  • 2022-01-26
  • 2021-11-29
  • 2021-12-14
  • 2021-05-21
  • 2022-12-23
相关资源
相似解决方案