1

There is a log folder on my disk, whose rotation policy is as follows

"/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
}

There is a set of logfiles in the /mnt/foo/shared/log folder named indexer_cron_1.logto indexer_cron_4.log I want only these 4 files to be rotated for 14 days. How do I override this configuration? I thought of creating another configuration but the thought of duplicate rotations occured and I stopped this. I do not have a machine where I can test this before, hence asking here.

0

You can use globbing to do this which means that you will have to explicitly specify which log files should be rotated for 14 days and which not:

/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
}

These log files rotate for 14 days:

/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
}

There is no other simpler way how to include or exclude some log files from a rotation rule.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.