There's a way to do this?
Using our previous Apache error log example, logrotate will copy the file (e.g,. /var/log/apache2/error. log. 1) and then delete data from the original one—instead of renaming it—so the logging service can continue to write to the file without interruption.
The logrotate tool is commonly used to manage the process of log rotation, though logrotate itself is run through cron. The important files to pay attention to are: /usr/sbin/logrotate -- the logrotate command itself (the executable) /etc/cron.
The main logrotate configuration file is located at /etc/logrotate. conf . The file contains the default parameters that logrotate uses when it rotates logs.
Add an entry for your log fileAt the end of logrotate. conf, add the full path to your log file followed by open and close curly brackets. There are many options you can add like the frequency to rotate "daily/weekly/monthly" and the number of rotations to keep "rotate 2/rotate 3".
Set a really large value for the rotate
argument in the configuration section.
Even if you use a daily rotation, a value of rotate 365000
would provide for a thousand years of saved logs -- and chances are you may have switched your OS by then.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With