LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-20-2012, 01:39 AM   #1
ayush1440
Member
 
Registered: Dec 2007
Posts: 75

Rep: Reputation: 15
Logrotate help


Hello Friends,

I have Amazon Cloud account and configured Amazon linux. We are using tomcat on server. Tomcat logs need to rotate.

I successfully configured log rotate and it rotate logs as well. But log rotate creates archive file in same directory..

I want to configure logrotate such a way that it create every year & month directory and then put daily logfiles inside it.

Here is sample of directory structure..

Help would really appreciated.

Code:
--2011 (Year)
 |
 |- Jan (Month)
   |
   |
   | - 01 (Date)
      |
      |- catalina.out
      |- hostmanager**.out
   | - 02 (Date)
      |
      |- catalina.out
Here is my configuration for tomcat

Code:
/tomcat/logs/catalina.out {
 copytruncate
 daily
 rotate 7
 compress
}
Also I require to copy compressed logs to another server. So please help me on that too.

Also welcomed some other tool or advise.

Help would be really appreciated.

Thanks in advance.
 
Old 03-20-2012, 01:53 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello,

You could add 'dateext' and 'dateformat' to your logrotate configuration to have an additional identifier on your archived logs. Next you could write a shell script to move those files to the correct directory (year/month) after rotating with the postrotate/endscript indicator (have a look at the man page for logrotate).

But... If you're going to copy the compressed files to a remote server why don't you set everything up to use a syslog-ng server which will provide you with what you need (the date structure in directories) and much more additional things like filtering, alert messages and so on.

Kind regards,

Eric
 
Old 03-20-2012, 04:13 AM   #3
ayush1440
Member
 
Registered: Dec 2007
Posts: 75

Original Poster
Rep: Reputation: 15
Thanks a lot for replying.

Quote:
Originally Posted by EricTRA View Post
Hello,

You could add 'dateext' and 'dateformat' to your logrotate configuration to have an additional identifier on your archived logs. Next you could write a shell script to move those files to the correct directory (year/month) after rotating with the postrotate/endscript indicator (have a look at the man page for logrotate).
I understand dateext & dateformat string but is it create directory structure as I said?

Quote:
But... If you're going to copy the compressed files to a remote server why don't you set everything up to use a syslog-ng server which will provide you with what you need (the date structure in directories) and much more additional things like filtering, alert messages and so on.

Kind regards,

Eric
I am on live Production server, So I think this will take long time and may be lots of configuration,. Isn't is there any simple solution like a script to scp & exec after logrotating?

Again thanks for replying, I am new to this things So please help me.
 
Old 03-20-2012, 06:31 AM   #4
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hi,

No, the 'dateext' and 'dateformat' will only add the date to the logfile instead of just a number in the format you indicated using dateformat (consult man page for more detail). This will not create any directory structure. For that part I referenced to writing a script to do that, which script you could put in a cronjob to check for newly created files on a predefined frequency and move said files if they exist to the correct directory and create said directory if it doesn't exist.

I just pointed out syslog-ng as a solution, you could also use rsyslog, which is a lot easier to setup but I'm not sure it will offer you the same functionality (creating directories automatically) as syslog-ng. If you don't want to setup / configure remote logging then you'd have to write your own script to move the files to another server with for example scp withing the postrotate/endscript indicator inside the logrotate configuration.

Kind regards,

Eric
 
  


Reply


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
[SOLVED] logrotate or logrotate.conf; problems with sftp slufoot80 Linux - Server 1 11-05-2011 07:50 AM
logrotate dnaqvi Linux - General 3 04-20-2010 04:36 PM
I need a little help with logrotate Udi Linux - Newbie 1 02-02-2009 11:01 AM
logrotate invent Linux - Enterprise 1 08-19-2008 08:45 AM
Logrotate Help! MaverickApollo Linux - Software 3 02-19-2004 12:09 PM


All times are GMT -5. The time now is 03:31 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration