SvennD
Rotate rsyslog logs, using logrotate
February 25, 2016

Rotate rsyslog logs, using logrotate

Posted on February 25, 2016  •  2 minutes  • 396 words  •  Suggest Changes

Ow boy, after splitting of my logfile the file kept on growing, and grep’ kept on becoming slower, now I initially thought rsyslog also managed the rotation, but I’m wrong, in fact its logrotate that does the work. So lets rotate the heck out of that long file!

Configuration
the vendor specific configurations can be found here : /etc/logrotate.conf
For Centos 7.2 :

weekly
rotate 4
create
dateext

include /etc/logrotate.d

Its kind of self explaining but here goes, these are the “default” values for the files :

note : I use _logrotate 3.8.6 _ some options might not be available on older systems.

Specific
So I created a file /etc/logrotate.d/tape with the following :

/var/log/tape.log {
    rotate 52
    weekly
    create
    missingok
    delaycompress
    compress
}

this means :

**Test drive
** Good thing you don’t have to wait a [daily|weekly|monthly|yearly] for it to work, you can just test the configuration like this :

logrotate -v /etc/logrotate.d/tape

You can also force it to rotate it using the -f flag

logrotate -v -f /etc/logrotate.d/tape

One of the better man pages by the way! Check man page here.

Bam that’s it! Happy rotating !

Support

If you enjoyed this website, consider buying me a Dr. Pepper

Buy me a Dr PepperBuy me a Dr Pepper