Loosing STDOUT after file rotation

Peter Pentchev roam at ringlet.net
Tue Apr 27 01:41:19 PDT 2004


On Fri, Apr 02, 2004 at 05:19:42PM +0200, Dag-Erling Sm?rgrav wrote:
> James Housley <jim at thehousleys.net> writes:
> > I have a program that I have the is supposed to run forever.  I log
> > any output to a log file.  It is run in a startup script like thie:
> >
> > program_name >> $err_log 2>&1
> >
> > The problem is that after newsyslog rotates the $err_log file, no more
> > data is written to the file.  I can not stop and restart the program.
> > I can accept a signal.  But what do I need to do in "program_name" to
> > allow the data to be written after the "rotation" of the file.
> 
> There is not much you can do unless you modify your program to write
> directly to the log file instead of stdout (in which case you just
> need to re-open the log file when you get a SIGHUP), or use something
> like Apache's logrotate instead of newsyslog (pipe the program's
> output to logrotate, which takes care of the rest)

Or, as an alternative to Apache's logrotate, there is multilog from
djb's daemontools package - ports/sysutils/daemontools,
http://cr.yp.to/daemontools.html

G'luck,
Peter

-- 
Peter Pentchev	roam at ringlet.net    roam at sbnd.net    roam at FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
because I didn't think of a good beginning of it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20040427/6ec4d083/attachment.bin


More information about the freebsd-hackers mailing list