How To Logrotate Custom Logs

If your are creating a custom log and would like to use logrotate, then this tutorial is for you. In this example I will show you how I am using logrotate to rotate a custom log created during Unison File Synchronization. The log file I will be rotating is at: /var/log/unison.log. We will also create a file at /etc/logrotate.d/unison, this file tells logrotate.d how to handle our custom log file. Below are the contents:

/var/log/unison.log {
  rotate 7

Of course this is a basic example, however many other options for logrotate.d are available to extend its functionality and documentation can be found here. To verify that your logrotate script is correct, run the following command.

logrotate -d /etc/logrotate.d/unison

In the event you need to run your logrotate script immediately, use:

logrotate -f -v /etc/logrotate.d/unison
Did you find this article useful? Why not share it with your friends?

2 thoughts on “How To Logrotate Custom Logs

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.