11
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

deletedされたlogをプロセスが掴みっぱなしだったときのはなし

Last updated at Posted at 2015-04-01

#logrotate設定
nginxのlogがdeletedされてるのに、プロセスがいつまでも掴んだまま。
結果、サーバー容量死亡のお知らせ。

logrotateの設定ファイル(/etc/logrotate.d/nginx)を変更。
具体的には、postrotateのコマンドをkillコマンドに変更した。

変更前
/var/log/nginx/*.log {
    create 0644 nginx adm
    daily
    rotate 7
    missingok
    notifempty
    compress
    sharedscripts
    postrotate
        /etc/init.d/nginx reopen_logs
    endscript
}
変更後
/var/log/nginx/*.log {
    create 0644 nginx adm
    daily
    rotate 7
    missingok
    notifempty
    compress
    sharedscripts
    postrotate
        [ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
    endscript
}

reopenとkillは意味が同じはずなので、なぜこれでできたの?と知り合いに聞かれて私もわからん…。
純粋に再起動後にlogrotateおかしくなったので、そのときのrestartがうまくいかなかったのかも?

11
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?