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) Code:
/tomcat/logs/catalina.out { Also welcomed some other tool or advise. Help would be really appreciated. Thanks in advance. |
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 |
Thanks a lot for replying.
Quote:
Quote:
Again thanks for replying, I am new to this things So please help me. |
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 |
All times are GMT -5. The time now is 08:14 PM. |