1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

お前らがlogrotate書いてる時に俺はnewsyslogを書いてる

Posted at

FreeBSD最高機能であるZFSやjails, セキュリティ機能だけがピックアップされがちですが
こういった日常的に使える地味な機能も良いゾってハナシ

機能としてはlogrotateと大差ないけど、直感性が違う

では、一般的な例として
Nginxのaccess|error.logを24時間ごとにローテーションして7世代で圧縮保存後、シグナル送ってログファイルを再オープンするって設定をする。

という設定を行うとすると

logrotate

/var/log/http-*.log {
    daily
    rotate 7
    compress
    delaycompress
    missingok
    notifempty
    create 0640 root wheel
    sharedscripts
    postrotate
        [ -s /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
    endscript
}

これだけで完結せず、cronで間隔を設定する必要がある...
もぅマヂ無理

newsyslog

/var/log/http-*.log  root:wheel  640  7 *  $D00  ZB  /var/run/nginx.pid 10

これよ...
間隔の設定ここでしたいんよ...
システムデーモンとして設定されてるのでcron不要なんよ...

Macでも/etc/newsyslog.d以下に設定書けるから明日から使っていこうな!

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?