[clug] rotating log files

Alex Satrapa grail at goldweb.com.au
Thu Mar 22 23:55:30 GMT 2007


On 23/03/2007, at 10:22 , Robert Edwards wrote:

> Can anyone suggest to me why rotating log files would ever be
> considered a "Good Idea"?

The main reason is to prevent you having to parse through a 16GB file  
to find the log entry you're looking for, is my guess.

But the rotating through ".0" -> ".9" etc never made sense to me. I  
just lived with it because I was too lazy to go fix logrotate to do  
it "the right way".

> To me, a much better approach would be to date-stamp each of the
> log files each day/week/month (configurable) and not to rotate the
> file names.

Aside from rotating the file names, remember each file has a "last  
modified date" which usually indicates the last time something was  
written to that file. "ls -lt" will sort by date, then you pick the  
youngest date older than the events of interest. But you know that  
already, so why am I telling you that? Perhaps I just like the sound  
of my own typing?

> Does such an alternative exist (before we write our own)? What should
> I search for?

Apparently logrotate 3.7.4 and greater support the "dateext" option.  
I only have 3.7 on my machines so I can't tell you more details, but  
it was apparently added to address the exact issue you are  
experiencing (multiple redundant backups of the same log file with  
different names).

Alex




More information about the linux mailing list