Tomcat – Why is logrotate not rotating logs Tomcat access logs on aws centos 6.3

amazon-web-servicescronlog-fileslogrotatetomcat

I have the following file in /etc/logrotate.d:

/usr/share/apache-tomcat/logs/*.access {
nodateext
copytruncate
daily
rotate 7
notifempty
postrotate
EXT=`date --date='-1 day' +%Y-%m-%d`
/bin/gzip $1.1
mv $1.1.gz  $1.$EXT.log.gz
endscript
create 0640 tomcat tomcat
}

It should take a file servername.access and move it to servername.access.2013.02.24.log.gz

When I run manually sudo /usr/sbin/logrotate -v /etc/logrotate.d/tomcat it works
From inside the cron daily it does not work

contents of /var/lib/logrotate.status

logrotate state -- version 2
"/var/log/yum.log" 2013-1-1
"/var/log/up2date" 2012-12-12
"/var/log/sssd/*.log" 2012-12-12
"/var/log/dracut.log" 2013-1-1
"/var/log/httpd/*log" 2013-2-12
"/var/log/wtmp" 2012-12-12
"/var/log/spooler" 2013-2-24
"/usr/share/apache-tomcat/logs/AWS001.access" 2013-2-24
"/var/log/btmp" 2013-2-12
"/var/log/rhsm/rhsmcertd.log" 2013-2-24
"/var/log/maillog" 2013-2-24
"/var/log/php-fpm/error.log" 2013-2-24
"/var/log/cups/*_log" 2012-12-12
"/var/log/secure" 2013-2-24
"/var/log/rhsm/rhsm.log" 2013-2-24
"/var/log/messages" 2013-2-24
"/var/account/pacct" 2012-12-12
"/var/log/cron" 2013-2-24

output of /var/log/cron:

Feb 24 00:48:01 AWS001 run-parts(/etc/cron.daily)[13433]: starting logrotate
Feb 24 00:48:02 AWS001 run-parts(/etc/cron.daily)[13457]: finished logrotate

Has somebody an idea?

Best Answer

I finally got it to work

sudo crontab -u root -l (list jobs for user root in cron)
There was no jobs
sudo crontab -u root -e (edit crontab)
@daily /usr/sbin/logrotate -v /etc/logrotate.d/tomcat  >/dev/null 2>&1
save the file
sudo crontab -u root -l
one job for user root

I also added full paths in /etc/logrotate.d/tomcat as indicated by user quanta

Note: when you cat /etc/crontab it is still empty

I found my job in file /var/spool/cron/root
Thanks to all who answered