[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Best way to rotate log files?
On Thu, 2 May 1996, Ken Lalonde wrote:
> There's no need to bother with SIGHUPs if you roll
> your logs this way:
> cp log elsewhere
> > log
> The router and scheduler set the O_APPEND flag on
> the logfile, so all writes happen at the current EOF.
Hmmm ... would a script that does file locking (i.e. with a call like
'flock()) work? Call the line you want to chop the log at 'n'. Write all
lines until 'n' out to where you want to rotate your log to. Then lock
the logfile, write line 'n' and succeeding lines out to a temporary file,
write the temporary file back to the logfile and unlock.