0

I am setting up logrotate & realized that a few of the options are either incorrectly explained/understood.

My logrotate rotate 52 keyword is creating 52 files of the same log every time it rotates (daily).

localhost_access_log.2014-10-23.txt.1.gz
localhost_access_log.2014-10-23.txt.2.gz
localhost_access_log.2014-10-23.txt.3.gz
localhost_access_log.2014-10-23.txt.4.gz
localhost_access_log.2014-10-23.txt.5.gz
localhost_access_log.2014-10-23.txt.6.gz
localhost_access_log.2014-10-23.txt.7.gz
localhost_access_log.2014-10-23.txt.8.gz
localhost_access_log.2014-10-23.txt.9.gz
localhost_access_log.2014-10-23.txt.10.z
localhost_access_log.2014-10-23.txt.11.gz
localhost_access_log.2014-10-23.txt.12.gz
localhost_access_log.2014-10-23.txt.13.gz
localhost_access_log.2014-10-23.txt.14.gz

I haven't found a way for it to delete older log files using its in-built capability.

Can someone explain why it would make 52 compressed parts of a single day log file ?
How can I get it to delete logs older than 90 days using its inbuilt options like maxage ?

My config file is:

/var/log/localhost_access_log.*.txt {
  copytruncate
  daily
  rotate 52
  compress
  missingok
  create 640 tomcat7 tomcat7
}
Sven
  • 98,649
  • 14
  • 180
  • 226
deppfx
  • 429
  • 3
  • 13

2 Answers2

0

For the first question perhaps you should post your config.

The option to delete logs older than 90 days is

maxage 90
Paolo Benvenuto
  • 241
  • 5
  • 13
0

I think the problem here is the "*" in your config and then having the date in the filename for your logfile. You basicly tell the logrotate to keep 52 versions of every file that matches the "/var/log/localhost_access_log.*.txt" expression, which in your case is one logfile for each day. I'm not sure though why it immediately creates all 52 versions, but in the end you will have one compressed file containing your logs and 51 empty files.

To fix this config:

  • either use logrotate to manage the dailey rotation or the daemon, if you want to use logrotate remove the date from the log filename
  • if you want the daemon to handle log rotation and have the date in the file name, remove the rotate option and add the maxage for how many days you want to keep your logfiles
  • remove the create option, it doesn't do anything anyway as I said in my comment above
dadriel
  • 106
  • 5