tomcat 日志切割
使用CentOS6U5自带的logrotate程序来解决catalina.out的日志轮转问题。这种方式比较简单。在/etc/logrotate.d/目录下新建一个名为tomcat的文件:[root@k8s133-master logrotate.d]# cd /etc/logrotate.d/[root@k8s133-master logrotate.d]# vi tomcat/data/rsd
1.使用CentOS6U5自带的logrotate程序来解决catalina.out的日志轮转问题。这种方式比较简单。在/etc/logrotate.d/目录下新建一个名为tomcat的文件:
[root@k8s133-master logrotate.d]# cd /etc/logrotate.d/
[root@k8s133-master logrotate.d]# vi tomcat
/data/rsd/svd/tomcat/logs/catalina.out{
copytruncate
daily
rotate 7
missingok
compress
size 16M
}
执行:logrotate /etc/logrotate.conf
2.
[root@k8s133-master logrotate.d]# vi /usr/local/src/clear_tomcat_logs.sh
#!/bin/bash
logs_path="/data/rsd/svd/tomcat/logs/"
find $logs_path -mtime +1 -name "localhost.*.log" -exec rm -rf {} \;
find $logs_path -mtime +1 -name "localhost_access_log.*.txt" -exec rm -rf {} \;
find $logs_path -mtime +1 -name "catalina.*.log" -exec rm -rf {} \;
find $logs_path -mtime +1 -name "manager.*.log" -exec rm -rf {} \;
find $logs_path -mtime +1 -name "host-manager.*.log" -exec rm -rf {} \;
find $logs_path -mtime +1 -name "catalina.*.out" -exec rm -rf {} \;
find $logs_path -mtime +1 -name "catalina.out" -exec rm -rf {} \;
[root@k8s133-master logrotate.d]# crontab -e
00 01 * * * /bin/sh /usr/local/src/clear_tomcat_logs.sh
更多推荐
所有评论(0)