2

I have a number of files in /var/log/myapp/ that end in .log. So I've created a

/var/log/myapp/*.log {
  daily
  create 644
  rotate 90
  compress
  missingok
}

And this works perfectly well. I have a number of different log types in here and I want to change the retention on just some of the access logs (access_log_.log) to have a retention of just 45 days. How then do I single these two out and change the retention time? If I append a new block like this:

/var/log/myapp/access_log_*.log {
  daily
  create 644
  rotate 45
  compress
  missingok
}

Then it first does it's usual log rotate and then it log rotates those rotations creating a huge inception like mess. What is the better way to do this?

chicks
  • 3,793
  • 10
  • 27
  • 36

2 Answers2

1

Either specify more exact glob patterns, or put the different rotation schedule logs into separate directories. Logrotate's configuration language is so very, very limited.

womble
  • 96,255
  • 29
  • 175
  • 230
1

You will have to ensure that the log name expansions do not include each other.

I would first of all try to rename the access_log_*.log, perhaps access_log_*.txt (or even just remove the suffix) or put them into a different directory.

Don't forget you can provide a list of logs for logrotate to act upon too rather than a regular expression.

user9517
  • 115,471
  • 20
  • 215
  • 297