Log Rotation

Marc Wiz marc at wiz.com
Sun Dec 28 10:47:41 PST 2003


On Sun, Dec 28, 2003 at 01:24:02PM -0500, Scott W wrote:
> 
> The easy solution is to see if any of the log rotation scripts have the 
> 'right' behavior...if not, you can write your own script to do it, test 
> it by rotating the logs and then intentionally doing something to 
> produce log output (depending on your log level)...if you get the log 
> output, everything's happy.  What it should be doing is this (and a side 
> effect is you shouldn't run into log problems on other apps either):
> 1.  Copy the log file locally, using whatever naming convention you 
> want, eg logname.(massaged date/time stamp like $(date | cut -f' '))
> 2.  Truncate the existing log via cat /dev/null > original logfile . 
> This allows the logging progam to continue to log without an invalid fd..
> 3.  gzip or move the copied logfile to wherever, gzip it etc..
> 

And it does help to check the documenation for the particular program
doing the logging to see if it has a way of switching the logs
via some external condition (e.g. a signal) or whether you can specify
when it should rotate the log.

Another possibility (although somewhat of a hack) is to stop the program,
rotate the log and then start the program up again.   Perhaps not for
a 24x7 environment but it does work.

Marc

-- 
Marc Wiz
marc at wiz.com
Yes, that really is my last name.


More information about the freebsd-questions mailing list