NGINXのlogrotate

2022/03 の作業


インストール時に作成してもらった logrotate の設定を修正。

アーカイブを1日毎にするんで、ファイル名に日付をつける事にする。

$ sudo vi /etc/logrotate.d/nginx
/var/log/nginx/*log {
    daily
    rotate 10
    missingok
    notifempty
    compress
    sharedscripts 
    dateext                  # <-追加
    dateformat _%Y-%m-%d_%H  # <-追加
    postrotate
        /bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true
    endscript
}