[CentOS] Sort logfiles at rotation time
Jorge Fábregas
jorge.fabregas at gmail.com
Mon Nov 9 14:29:51 UTC 2009
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
whatever-site-access.log.20091031.gz
whatever-site-error.log.20090930.gz
whatever-site-error.log.20091031.gz
Well...these are sorted (within the same type of file: access... error). 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).
HTH,
Jorge
More information about the CentOS
mailing list