logrotate
logrotate
デバックテスト
logrotate -d /etc/logrotate.d/nginx
強制実行
logrotate -f /etc/logrotate.d/nginx
logrotareの実行順番
1. cron
※cronが起動
2. /etc/anacrontab
1 5 cron.daily nice run-parts /etc/cron.daily
※cron.dailyが毎日稼働
3. /etc/cron.daily/logrotate
/usr/sbin/logrotate /etc/logrotate.conf
※logrotate.confが実行
4. logrotate.conf
include /etc/logrotate.d
※logrotate.d配下がインクルード
logrotate例
syslog
/var/log/cron /var/log/maillog /var/log/messages /var/log/secure /var/log/spooler { sharedscripts postrotate /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null | | true endscript }
httpd
/var/log/httpd/*log { missingok notifempty sharedscripts delaycompress postrotate /sbin/service httpd reload > /dev/null 2>/dev/null | | true endscript }
td-agent
/var/log/td-agent/td-agent.log { daily rotate 30 compress delaycompress notifempty create 640 td-agent td-agent sharedscripts postrotate pid=/var/run/td-agent/td-agent.pid test -s $pid && kill -USR1 "$(cat $pid)" endscript }
- 最終更新:2017-05-09 14:56:23