Linux httpdのログローテーション

httpdのログローテーション

ヴァーチャルホストで複数のアクセスログがあるためデフォルトの
httpdのログローテーションファイルを編集して追加する

# vi /etc/logrotate.d/httpd


下記の1行目のようにローテーションするファイルを追加すればよい。

/var/log/httpd/*log /home/www/hage/logs/*log /home/www/hoge/logs/*log {
    missingok
    notifempty
    sharedscripts
    monthly
    rotate 12
    postrotate
        /bin/kill -USR1 `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
    endscript
}


設定したらテスト

# logrotate -f httpd

-f でローテーションを強制実行