Posted 25 February, 2016
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 !
If you enjoyed this article, please consider buying me a Dr Pepper.
Fuel the beast!
Buy me a Dr Pepper
[…] https://www.svennd.be/rotate-rsyslog-logs-using-logrotate/ […]