Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How i configure logrotate to not delete my log files after rotation?

There's a way to do this?

like image 742
Guilherme Avatar asked Aug 05 '09 00:08

Guilherme


People also ask

Does logrotate delete old logs?

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.

What is the service used to rotate log files automatically?

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.

Where are rotated logs stored?

The main logrotate configuration file is located at /etc/logrotate. conf . The file contains the default parameters that logrotate uses when it rotates logs.

How do I add log to rotated file?

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".


1 Answers

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.

like image 108
Dirk Eddelbuettel Avatar answered Nov 15 '22 01:11

Dirk Eddelbuettel