Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-25-2010, 02:34 AM   #1
Registered: Dec 2007
Posts: 89

Rep: Reputation: 16
logrotate not rotating files with date extension


I am trying to configure logrotate on APP/DB servers.As per my backup policy,logs will compress in daily basis and and will be moved to a Central storage device.My tomcat generate several application logs with date extension as well as .log extension.For eg
app.log,app.log.2010-10-23-14,catalina.out,catalina.2010-10-25.log etc.

Currently my tomcat logrotation /etc/logrote.d/

#cat /etc/logroate.d/tomcat/
/usr/local/tomcat/logs/*log {
rotate 2

But its rotating logs only with .log app.log.2010-10-23-14 (with date extension) is not rotating.If i put "*" instead of "*log",its rotating all files including rotated files.
How can i rotate files which is having date extension.Also i dont want to keep rotated logs for more than 3 days.How can i solve the Issue..

Advanced Thanks,

Last edited by ajayan; 10-25-2010 at 02:48 AM.
Old 10-25-2010, 07:08 PM   #2
Registered: Oct 2010
Location: New England, USA
Distribution: OpenSUSE/Slackware64/RHEL/Mythbuntu
Posts: 187

Rep: Reputation: 39
The simplest way would be to have all log files end in .log. When the log file is created, have the date inserted before the last section of the file name. example: somedatabasefile.2010-10-25.log

The 'rotate' qualifier tells logrotate how many rotations to make before it deletes the old files. You have rotate 2, change it to rotate 3.

Here's the line from the man page:

rotate count
Log files are rotated count times before being removed or mailed to the address specified in a mail directive. If count is 0, old versions are removed rather than rotated.

Edit: You could also create a date variable to append to the file name. Like:
DATE='date %D'

Last edited by udaman; 10-25-2010 at 07:19 PM. Reason: Additional info


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
logrotate with date in filename ptp Linux - Newbie 1 04-14-2011 11:55 AM
Logrotate rotating daily when should rotate weekly nanda_martins Linux - Server 14 03-29-2010 01:24 PM
rotating/pruning files digity Linux - General 2 01-02-2010 03:21 PM
Logrotate/ bash script not rotating file noir911 Linux - Server 2 01-15-2009 04:56 PM
logrotate mishandles files with YYYY-MM-DD extension dthacker Linux - General 0 08-20-2004 10:53 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:16 AM.

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