他の構成を介してlogrotateの構成をオーバーライドする方法

他の構成を介してlogrotateの構成をオーバーライドする方法

マイディスクには、次の循環ポリシーを使用するログフォルダがあります。

"/mnt/foo/shared/log/*.log" {
  # rotate the files daily
  daily
  # Save the last 7 days worth of logs before deleting
  rotate 7
  # missing file is not an error case - just ignore.
  missingok
  # this is important for the logs
  copytruncate
}

フォルダには、「14日間この4つのファイルだけを回転させたい」/mnt/foo/shared/logというログファイルセットがあります。この構成をどのようにオーバーライドできますか?別の構成を作ってみようかと思いましたが、繰り返される回転の考えが生じてそれを止めました。以前はこれをテストするコンピュータがなかったので、ここに質問します。indexer_cron_1.logindexer_cron_4.log

ベストアンサー1

globbingを使用してこれを行うことができます。つまり、14日間に回転するログファイルと回転しないログファイルを明示的に指定する必要があります。

/mnt/foo/shared/log/other_log_file_*_1.log
/mnt/foo/shared/log/other_log_file_*_2.log
/mnt/foo/shared/log/other_log_file_*_3.log
{
  # rotate the files daily
  daily
  # Save the last 7 days worth of logs before deleting
  rotate 7
  # missing file is not an error case - just ignore.
  missingok
  # this is important for the logs
  copytruncate
}

このログファイルは14日間循環します。

/mnt/foo/shared/log/indexer_cron_[1234].log
{
  # rotate the files daily
  daily
  # Save the last 14 days worth of logs before deleting
  rotate 14
  # missing file is not an error case - just ignore.
  missingok
  # this is important for the logs
  copytruncate
}

循環ルールに特定のログファイルを含めたり除外したりする簡単な方法はありません。

おすすめ記事