Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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