Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I noticed that one of our tomcat apps is archiving old files in the format "catalina.YYYY-MM-DD.log" and these are adding up and taking space (4 months worth so far)
I want to use logrotate to only retain the last 14 days of these logs.
So I created an app-specific logrotate config file at /etc/logrotate.d/myapp
/path/to/my/app/logs {
daily
maxage 14
rotate 0
}
After running 'logrotate -fv /etc/logrotate.d/myapp', it renamed those logfiles by appending a ".1" to the end each log. But did not delete any logfiles.
I've tried running the same command each day for several days, but still it has not deleted any old logfiles.
Am I doing something wrong?
Or perhaps I'm not understanding how it works? Do I have to wait 14 days for the deleting to begin?
I've spent several hours googling and reading examples, man pages, etc with no luck.
As far as logrotate is concerned, each of those files is a separate log file from a separate program that needs to be rotated separately. logrotate intends to keep 14 of EACH of those files, not 14 total. That's why it stuck a ".1" onto each one, it was the first of 14 log files of that name.
You don't need logrotate, your program is already doing its own rotation, what you need is a simple cron job to delete any log files older than XX days.
Ah, that explains things.
Currently tomcat is creating these "catalina.YYYY-MM-DD.log" files due to the JULI configuration in logging.properties for my app's conf folder.
So there's no way for logrotate to handle the deletions for me?
I have to add a separate cronjob instead?
Or do you know of a better practice to follow (ie let logrotate handle everything for my tomcat instance's logfiles, and don't use JULI logging.properties)?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.