LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 05-12-2014, 02:44 PM   #1
BlueKayak
LQ Newbie
 
Registered: May 2014
Posts: 2

Rep: Reputation: Disabled
Logrotate not working as desired


OS = CentOS 4.8
logrotate 3.7.1


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.

Thanks
 
Old 05-12-2014, 03:12 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
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.
 
Old 05-12-2014, 03:21 PM   #3
BlueKayak
LQ Newbie
 
Registered: May 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks suicidaleggroll,

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)?
 
Old 05-12-2014, 03:28 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
I have no experience with JULI/tomcat, so I can't help there.

Here's a little read on removing date stamped files with logrotate, with another note about using find in a cron job to actually do the work:
http://stackoverflow.com/questions/1...-stamped-files
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Logrotate stopped working slufoot80 Linux - Newbie 4 03-05-2013 10:07 AM
Logrotate not working ankitjainfsl Linux - Newbie 3 09-10-2012 02:29 AM
Stunnel+haproxy+apache not working as desired hamzar.pm Linux - Security 1 09-01-2012 12:12 PM
haproxy+stunnel+apache not working as desired hamzar.pm Linux - Server 0 08-31-2012 03:42 AM
[SOLVED] less than condition in if statement not working as desired samasat Linux - Newbie 11 06-09-2012 05:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration