Puppet-izing my lab’s machines, I phone it in a little and used the following logrotate definition.
logrotate::rule { 'postfix':
path => '/var/log/mail.*',
rotate => 1000,
compress => true,
missingok => true,
rotate_every => 'week',
postrotate => 'invoke-rc.d syslog-ng reload > /dev/null',
}
This did terrible, terrible things.
-rw-r----- 1 root adm 0 Dec 2 07:35 mail.log.1.gz.2.gz.2.gz.4.gz
-rw-r----- 1 root adm 0 Dec 15 07:36 mail.log.1.gz.2.gz.3.gz
-rw-r----- 1 root adm 0 Dec 15 07:36 mail.log.1.gz.2.gz.3.gz.1.gz
-rw-r----- 1 root adm 0 Dec 15 07:36 mail.log.1.gz.2.gz.3.gz.1.gz.1.gz
-rw-r----- 1 root adm 0 Dec 15 07:36 mail.log.1.gz.2.gz.3.gz.1.gz.1.gz.1.gz
I really didn’t want to clean this up by hand on my hosts. This is where tidy
came in!
tidy { '/var/log': age => '0', backup => false , recurse => true , matches => ['mail.err.?.gz.*', 'mail.log.?.gz.*'], rmdirs => false, }
This brought me back to a nice sane /var/log
directory