I have various kinds of logs.
I've around 10 glassfish domains.
Each of them have separate logs.
application.log
and server.log
The older logs go like this
application.log_2023-10-06
whereas today's logs go like this
application.log
Then I have some tomcat and java servers as well which have catalina.out
and wrapper.log
.
wrapper.log is changing its time by itself i.e yesterday's log (today is 10-07) will be wrapper.log_2023-10-06
.
But all of catalina.out
remains in same file. It contains logs of multiple days, weeks and sometimes months.
Currently I am doing this.
find /path/to/glassfish/domain/logs -mtime +3 -type f -name 'application.log_*' -exec rm {} \;
find /path/to/glassfish/domain/logs -mtime +3 -type f -name 'server.log_*' -exec rm {} \;
find /path/to/java/server/logs -mtime +3 -type f -name 'wrapper.log_*' -exec rm {} \;
And then putting a cronjob to run it at 23:59 everyday.
I am not going to lie, this is really tedious thing. Specially because there are 10 different domains and 5 different java servers and 3 different tomcat servers in this linux server. And I am administering 20+ different servers.
Plus, to add pain to my work, the glassfish domains and tomcat and java servers name are different in each of those servers. Please tell me a good way to logrotate?
I've heard about logrotate
but I am not sure how that would be any efficient in my case and how I would use that? I have read about that though.
I'm not doing anything for catalina.out
as I got no idea.