I am looking for ways to use logrotate to delete "catalina.*.log" which is older than 30 days. By default catalina.log is rotating daily. I would like to know the procedure to delete these files older than 30days using logrotate and not using a script.
1 Answer
It's very difficult and obscure for catalina
logs due to how Tomcat rotates them itself. I think a script is best, but it can be a one-liner 'script' cron job.
find /path/to/catalina/logs/catalina.*.log -mtime +30 -exec rm -f {} \;
Run it once a day.
-
I tried this, but it deletes all catalina.log files including current ones. /app/tomcat/apache-tomcat-8.0.18/logs/catalina.*.log { daily rotate 2 missingok } Commented Jan 13, 2016 at 20:21
-
-
Thanks Steven. I will end up using script. Would have been nice if there is some option using logrotate. I will keep checking.. Commented Jan 14, 2016 at 0:38