melguin has asked for the wisdom of the Perl Monks concerning the following question:

Long and powerful chants/prayers/encantations/wizardry may be needed for this one. Goodness knows I've already used up all of mine.

I am debugging a simple perl program on a Solaris box that includes a small section that does about the same thing as newsyslog (i.e. checks if a log file has reached a max size, if so it renames it, creates a new one and sends a SIGHUP to syslogd which makes syslogd write to the new file instead of the renamed one). However on some systems, under some configurations, this doesn't work correctly due to the fact that syslogd is ignoring the SIGHUP.

So I'm trying to find another way to keep the syslog file under a certain size, while moving what's already been logged in other files. Unfortunately, any log loss is unacceptable. Any ideas, pointers, etc?

thanks.

melguin.

Replies are listed 'Best First'.
Re: am coming to hate syslog
by bluto (Curate) on Nov 09, 2001 at 01:25 UTC
    Some syslogs allow piping to a command or a named pipe. The problem is that it's not supported on all syslogd's. If you could use that you could write your own backend (in perl of course) to rotate the log for you.

    Another way is to find out how (if) the syslogs that can't be SIGHUP'd can be refreshed another way. For example, AIX refreshes syslogd using the 'refresh' command. If you can't figure out another way, perhaps the syslogd is being spawned so that it ignores SIGHUP (by accident)?

    bluto

Re: am coming to hate syslog
by drinkd (Pilgrim) on Nov 09, 2001 at 19:26 UTC
    An untested solution that I think would work.

    Set up the syslogd to write to a named symbolic link. That way your perl script just needs to look to the link target, when it gets too big, just create a new file and change the link. No renaming, no moving, no fuss.

    Unfortunately not supported on Win32 boxes, but you said you're running Solaris.

    drinkd