Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

logrotate - compression files modified x number of days

Is there a way to get logrotate to only compress files modified X number of days ago (e.g. mtime +2)

like image 784
user353829 Avatar asked Dec 21 '10 01:12

user353829


1 Answers

One option could be to use logrotate to rotate to a different extension, then use logrotate to rotate into compressed files:

/var/log/raw.log {
  daily
  nocompress
  extension .old
  }

/var/log/*.old {
  daily
  compress
  delaycompress
  rotate 10
  }

This Rube Goldberg contraption will result in the following:

raw.log
raw.log.old
raw.log.old.1
raw.log.old.2.gz
raw.log.old.3.gz

Thus you have two archived days of logs which are uncompressed.

like image 96
ManicDee Avatar answered Oct 03 '22 02:10

ManicDee