I have created a policy to rotate catalina.out of tomcat, my cron service is running and I can even check the log to verify the jobs but I am not getting the desired output. Here is my code
/etc/logrotate.d/tomcat
/opt/tomcat7/logs/catalina.out {
copytruncate
rotate 7
compress
missingok
size 1k
}
/etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
* * * * * root /usr/sbin/logrotate -v /etc/logrotate.conf
* * * * * root env > /opt/env.output
/var/log/cron
Apr 24 14:49:01 staging2 CROND[30862]: (root) MAIL (mailed 5331 bytes of output but got status 0x004b#012)
Apr 24 14:50:01 staging2 CROND[30903]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Apr 24 14:50:01 staging2 CROND[30902]: (root) CMD (/usr/sbin/logrotate -v /etc/logrotate.conf)
Apr 24 14:50:01 staging2 CROND[30901]: (root) CMD (env > /opt/env.output)
Apr 24 14:50:01 staging2 CROND[30893]: (root) MAIL (mailed 5376 bytes of output but got status 0x004b#012)
Apr 24 14:51:01 staging2 CROND[30938]: (root) CMD (/usr/sbin/logrotate -v /etc/logrotate.conf)
Apr 24 14:51:01 staging2 CROND[30937]: (root) CMD (env > /opt/env.output)
Apr 24 14:51:01 staging2 CROND[30932]: (root) MAIL (mailed 5331 bytes of output but got status 0x004b#012)
Apr 24 14:52:01 staging2 CROND[30975]: (root) CMD (/usr/sbin/logrotate -v /etc/logrotate.conf)
Apr 24 14:52:01 staging2 CROND[30976]: (root) CMD (env > /opt/env.output)
Apr 24 14:52:01 staging2 CROND[30970]: (root) MAIL (mailed 5331 bytes of output but got status 0x004b#012)
I can clearly see the job is executed every minute and it should rotate catalina file but it is not doing that, if I run the command /usr/sbin/logrotate -v /etc/logrotate.conf
manually it does the job.