On Tuesday 29 January 2008, Porkchop wrote: > On 29/01/08 21:45 -0500, Chris Knadle wrote: > > The script itself may not need to know about the rotation. In the > > logrotate or logrotate.d/ setup you can probably add a postroate command > > to restart the script after the log rotation to keep the script from > > continuing to read the old file after a new one has been created. > > syslog-ng can do things like make the destination logfile > "/log/$year/$month/$day/$host.log". No external log rotation to fail, > possibly reconfigure every time you add a new server (like I said, > hundreds of them)... > -porkchop
Oh -- so when the day changes there's no logrotate -- syslog itself is using the day in the path, so when the date changes so does the log file that's written to. I see it. Well, since you can't restart the script to read the new log file during the external logrotate that doesn't happen, the next thing you could do would be to have the script restarted by cron to switch to reading the new log file. There's a chance that the script may try to read the new log file before syslog has created it, and you don't want to wait a full minute to insure that syslog has made the file; this is probably exacerbated by there being so many logs that switch files based on the date, so there may be a lag. Hmm. What would really be nice is if there was some way to have syslog emit a signal or otherwise notify that it's switching files so that you could trigger on that event and have your script watch the new file. Perhaps you could use a file watching daemon to do that work -- as in use something like inotify to execute a command to restart the script when a new file is opened in /log/$year/$month/$day/, or when the old log file was closed -- either of which should only happen when syslog swiches files. But the problem is that if you actually READ the logs in that directory, that may also trigger the script to restart. Hmm. Donno. Hopefully the unix socket idea works, but there are other options if it doesn't. -- Chris -- Chris Knadle [EMAIL PROTECTED]
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Mid-Hudson Valley Linux Users Group http://mhvlug.org http://mhvlug.org/cgi-bin/mailman/listinfo/mhvlug Upcoming Meetings (6pm - 8pm) MHVLS Auditorium Feb 6 - DBUS Mar 5 - Setting up a platform-independent home/small office network using Linux
