The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem seen with logrotate rsravi74 Red Hat 1 02-16-2009 08:19 AM
logrotate question manouche UNIX for Advanced & Expert Users 1 01-29-2009 02:38 AM
logrotate bug? jjinno UNIX for Advanced & Expert Users 0 06-09-2008 05:24 PM
how to set size in logrotate.conf icehero UNIX for Dummies Questions & Answers 0 02-24-2008 04:41 AM
logrotate.conf fredao UNIX for Advanced & Expert Users 10 12-19-2006 09:57 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-16-2009
skmdu skmdu is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 111
logrotate with /etc/logrotate.conf file

Hi there,

I want to rotate the logfiles which are located in /var/log/jboss/tomcat*

so I have created a file named as 'tomat' in /etc/logrotate.d/tomcat with the following content.
Code:
# cat /etc/logrotate.d/tomcat
/var/log/jboss/tomcat_access_log*.log {
        daily
        nocreate
        rotate 1
        compress
        missingok
        postrotate
                find /var/log/jboss/ -iname 'tomcat_access_log*.gz' -type f -mtime +4 -exec rm -f \{\} \;
        endscript
}
As of now, /var/log/jboss has two tomcat access log files.

Code:
$ls -l /var/log/jboss
-rw-r--r-- 1 root root 46546 Oct 14 10:22 tomcat_access_log.2009-10-14.log
-rw-r--r-- 1 root root 46546 Oct 15 14:10 tomcat_access_log.2009-10-15.log
Content of default logrotate configuration file /etc/logrotate.conf
Code:
# cat /etc/logrotate.conf
# Let's do daily rotations on this system.
daily
rotate 30
create
compress
include /etc/logrotate.d
/var/log/wtmp {
        monthly
        create 0664 root utmp
        rotate 1
}
Executed the following command :

Code:
$ /usr/sbin/logrotate -v /etc/logrotate.conf
rotating pattern: /var/log/jboss/tomcat_access_log*.log  after 1 days (1 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/jboss/tomcat_access_log.2009-10-14.log
  log does not need rotating
considering log /var/log/jboss/tomcat_access_log.2009-10-15.log
  log does not need rotating
not running postrotate script, since no logs were rotated
not running postrotate script, since no logs were rotated
If you see the above logs, it doesnt rotate any log files...
Code:
$ls -l /var/log/jboss
-rw-r--r-- 1 root root 46546 Oct 14 10:22 tomcat_access_log.2009-10-14.log
-rw-r--r-- 1 root root 46546 Oct 15 14:10 tomcat_access_log.2009-10-15.log
When execute the same command with -f (force) option it is rotating and compressing the file..

My Doubt is :

I have logrotate to execute in the cron.daily.
Code:
# cat /etc/cron.daily/logrotate
#!/bin/sh

/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
chmod a+r /var/log/messages
I could able to see from the cron logs cron.daily was executed. But when I saw /var/log/jboss directory log files are there with out compressing and rotating.. But when I execute manually using -f option its rotation.

How to resolve this issue ? Any help is appreciated.
  #2 (permalink)  
Old 10-16-2009
TonyFullerMalv's Avatar
TonyFullerMalv TonyFullerMalv is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Location: Malvern, Worcs. U.K.
Posts: 740
I'd try increasing the:
rotate 1
to a larger number?
I know 1 means "1 extra" log file but I have never seen such a low number used.
  #3 (permalink)  
Old 10-17-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,873
The "problem" is that logrotate doesn't immediately switch any logs, but only after the rotation time for a file (in your case 1 day) has passed since it was first seen. So if you have 2 files, for the 14th and 15th of the month, and logrotate first sees them on the 16th of the month, they'll normally get rotated on the 17th.

With applications separating their logs by themselves, it's probably easier to work with find, eg:
Code:
find /var/log/jboss -type f -name '*.log' -mtime +1 -exec gzip -9 '{}' ';'
find /var/log/jboss -type f -name '*.log.gz' -mtime +4 -exec rm -f '{}' ';'
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0