[CentOS] Sort logfiles at rotation time

Mon Nov 9 14:37:18 UTC 2009
Stephen Nelson-Smith <stephen at atalanta-systems.com>

2009/11/9 Jorge Fábregas <jorge.fabregas at gmail.com>:
> On Monday 09 November 2009 10:00:32 am Stephen Nelson-Smith wrote:
>> I want to be certain that my apache and varnish logfiles are in strict
>> date order when rotated.  I'd like to run a sort command against them
>> before they're compressed.
>
> I use the dateext option in my logrotate configuration file so that rotated
> files have the date appended to the filename.  I also compress them so they
> end up like:
>
> whatever-site-access.log.20090930.gz

...

Yes, I do that too.

> If
> you want them strictly sorted by date you'll need to investigate.  I'm not
> sure if logrotate provides any facility in order to manipulate the "current"
> file being rotated so maybe you'll have to do this via a shells cript & cron
> (after logs are rotated).

That would be a shame...  it would work, but it would suck.

S.