newsyslog can't execute command?
olli at lurza.secnetix.de
Wed Sep 16 13:39:28 UTC 2009
Ferdinand Goldmann wrote:
> Have I overlooked something, or is it not possible with newsyslog to run a
> certain command after log rotation? :-(
A simple workaround is to write a small shell script that
stores its PID in a file, then runs in the background and
waits for a signal. It's a hack, but it works.
Basically, something like this will do:
echo $$ > /var/run/loghandler-foo.pid
while :; do
kill -STOP $$
do whatever you want with the log file
Make sure that shell script is run in the background
during system boot.
The newsyslog.conf entry should look like this:
/var/log/foo.log 644 3 100 * B /var/run/loghandler-foo.pid 19
The important thing is the number "19" at the end, which
will cause newsyslog to send SIGCONT to the shell script
after it has rotated the log file.
Alternatively you can also use the shell's built-in "trap"
command to use different signals.
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart
FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd
"What is this talk of 'release'? We do not make software 'releases'.
Our software 'escapes', leaving a bloody trail of designers and quality
assurance people in its wake."
More information about the freebsd-stable