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.
# 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.
$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
# 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 :
$ /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...
$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.
# 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.