Re: Log rotation
On Tuesday 01 April 2003 10:43, Matthew Daubenspeck wrote:
> I currently have a daemon logging each day's worth of activity into a
> separate daily log with the daemon-month.date.year format.
> Unfortunately, I cannot change the options of HOW it is logged or what
> it is named.
>
> I really only want to keep a weeks worth of logs, and have tried to use
> logrotate to handle all the rotation and removal. In short, it doesn't
> seem to be working. From what I can tell, logrotate is better suited at
> rotating a single log file, not logs that change the filename daily
> (such as an apache log).
Does each daily log have a name like Mon.log, Tue.log, Wed.log, etc.? Then
rotate them on a weekly basis.
In /etc/logrotate.d, add some stanzas such as:
/var/log/Mon.log {
weekly
rotate 1
postrotate
/* post rotate actions here if desired */
endscript
}
/var/log/Tue.log {
weekly
rotate 1
postrotate
/* post rotate actions here if desired */
endscript
}
Manipulate your date to "goose" the execution of cron to run the logrotate
function; should see Mon.log and Mon.log.1 after the logrotate.
>
> I guess the last resort would be to create some sort of shell script
> that would run in cron once a day and delete the oldest file in the log
> directory.
Sounds like a good solution if you have log files that always get a unique
name, like Mon.20030331.log. I am not sure if logrotate can handle filenames
like Mon.*.log.
>
> Any other ideas that I might be missing? Thanks.
--
Mike M.
Reply to:
- References:
- Log rotation
- From: Matthew Daubenspeck <matt@oddprocess.org>