TOP ▲ itcore TOPTIPSlogrotate.php  タグ:centos6 centos7 apache logrotate ログローテーション

centos apache ログローテーション | itcore 2019年

月毎 2年分

vi /etc/logrotate.d/httpd2
/var/www/*/log/*log {
    monthly
    missingok
    rotate 24
    ifempty
    sharedscripts
    delaycompress
    postrotate
        /bin/systemctl restart httpd.service > /dev/null 2>/dev/null || true # CentOS7
        service httpd restart > /dev/null 2>/dev/null || true # CentOS6
    endscript
}

パーミッション
# chown apache.apache /var/www/*/log
# chmod 755 /var/www/*/log

チェック
# logrotate -dv /etc/logrotate.d/httpd2
# logrotate -dv /etc/logrotate.conf

強制実行
# logrotate -f /etc/logrotate.d/httpd2

実行結果確認
cat /var/lib/logrotate/logrotate.status # CentOS7
cat /var/lib/logrotate.status # CentOS6