rsyslog、journalとlogrotate3 / 3

logrotate

/etc/logrotate.confと/etc/logrotate.dの各設定で、周期、世代数、圧縮、新しいfileのmodeなどを指定する。

/var/log/example.log {
    daily
    rotate 7
    compress
    missingok
    notifempty
    create 0640 root adm
}

dailyは日次、rotate7は保持する世代数を指定する。fileをrenameして新規fileを作る構成では、書込み中のdaemonが新しいfileをopenする処理も必要となる。postrotateで、そのdaemonが定める再openの手順を実行することがある。copytruncateは元のfileを保持してcopy後に切り詰めるが、間の書込みを失う可能性がある。logrotate -dは変更しないdebugで、実際のrotationの適用と区別する。

学習パスへ
参考資料