[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to rotate log files?



>> 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.
>
>I have two problems with this approach:
>  * it requires enough disk space to temporarily hold two copies of
>    the log, which can sometimes be a problem
>  * it can loose some log information (that written between the
>    "cp" seeing EOF and the creat() call of the ">"); on lightly
>    loaded systems this is not likely to be too much of a problem,
>    but on a heavily loaded system this could potentially loose
>    a few transactions
>
>                --Ken Pizzini

The log files are created at the first write to the log file, so a simple
"mv logfile elsewhere" should do. No info lost and you don't need double
the space. If a transaction is being logged during the move, the file
handle will already be open and the move shouldn't affect the write.


                           ,,,
                          (. .)
+----------------------o00-(_)-00o--------------------------------------+
| Dean Michaels                         Email   : dmichael@trlabs.ca    |
| Computer Systems Administrator        Phone   : (403) 441-3818        |
| Telecommunications Research Labs      Fax     : (403) 441-3600        |
| UN*X IS user friendly...............it's just picky about its friends |
+-----------------------------------------------------------------------+