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 { notifempty daily rotate 7 missingok compress }
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
Amazingly simple !
Thanks. Working!