【发布时间】:2015-04-24 18:40:11
【问题描述】:
我创建了一个将 catalina.out 轮换出 tomcat 的策略,我的 cron 服务正在运行,我什至可以检查日志以验证作业,但我没有得到所需的输出。这是我的代码
/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)
我可以清楚地看到作业每分钟执行一次,它应该旋转 catalina 文件,但它没有这样做,如果我手动运行命令 /usr/sbin/logrotate -v /etc/logrotate.conf 它会完成这项工作。
【问题讨论】:
标签: tomcat cron centos logrotate catalina