2

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 1

1

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.

3
  • 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 }
    – userstack
    Commented Jan 13, 2016 at 20:21
  • Updated - catalina logs look to be a bit of a pain.
    – smcstewart
    Commented Jan 13, 2016 at 21:30
  • Thanks Steven. I will end up using script. Would have been nice if there is some option using logrotate. I will keep checking..
    – userstack
    Commented Jan 14, 2016 at 0:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.