syslog log rotation
davidsen at tmr.com
Wed Apr 25 20:16:22 UTC 2001
In article <E14sBpt-0003FK-00 at g212.hadiko.de>,
Olaf Titz <olaf at bigred.inka.de> wrote:
| > In short, anything that deals with files that syslog is writing must
| > assume that syslog can be reloaded at any time, and therefore must
| > never create a window where a filename that syslog is configured to
| > write to does not exist.
| Why? As I see it the rotating program should not create the new log
| file at all, since syslog will do that as soon as it is reloaded (and
| at the same moment the old one gets closed). This is the same as with
| handling batch files from INN. This should work:
Syslog does no such thing. At least not remotely portably. And it can't
since the files would then get some default ownership and permissions.
What you want is to rename the file, create the new file with the old
permissions, and then ask syslog to refresh.
However, on many systems user programs can't refresh syslog either, so
you read and copy until you hit end of file, then truncate the file so
the next syslog write will still be in the right place.
I have a log rolling program and use it for non-news files, with an
option to treat a file as a syslog file, and try to hup syslogd if it
has permissions. Actualy it assumes it has permissions or it wouldn't be
told to do that, and complains if it doesn't work.
bill davidsen <davidsen at tmr.com>
CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.
More information about the inn-workers