/ var / logの2番目のログファイルが圧縮されない理由


12

/var/log/(Debian / Ubuntu)のログは次のように保存されます

x.log
x.log.1
x.log.2.gz
...

カーネルログ、syslogなどのように

ログ情報が増加するにつれて、それらは(すべてを1つのファイルに保持するのではなく)小さなファイルに分割して保存されることがわかります。2番目のファイル(x.log.1)が圧縮されないのはなぜですか。最近のログへのアクセスを簡単にすることと関係がありますか?

回答:


12

私はあなたに同意します、それは最近のファイルへのより簡単なアクセスを提供するだけであるべきです。とにかく、実際の動作はlogrotate 'delaycompress'ディレクティブによって決定されます。これは、「回転時にファイルを圧縮せず、次回は圧縮する」というものです。

歴史的な理由はlogrotateマニュアルにあります:

Postpone  compression of the previous log file to the next rotation 
cycle.  This has only effect when used in combination  with compress. 
It can be used when some program can not be told to close its logfile and 
thus might continue writing to the  previous log file for some time.

1
「(...)一部のプログラムがログファイルをすぐに閉じるように指示できない場合(...)」。Server Faultに関する投稿でこの精度を発見しました。
Ludovic Kuty 16

5

はい、これは、より新しいログファイルにアクセスしやすくするために行われます。logrotateオプションdelaycompressはこれを制御します。logrotateマンページから:

遅延圧縮

Postpone compression of the previous log file to the next rotation cycle.  
This only has effect when used in combination with
compress.  It can be  used  when  some  program
cannot be told to close its logfile and thus might 
continue writing to the previous log file for some time.

4
これらのオプションは/etc/logrotate.conf、およびの下のファイルで使用されます/etc/logrotate.d/*
slm
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.