newsyslog configuration issues

David Kelly dkelly at hiwaay.net
Thu Apr 24 10:53:07 PDT 2003


On Thu, Apr 24, 2003 at 09:32:50AM -0800, admin2 wrote:
> 
> 
> 
> FreeBSD 4.7 Stable
> 
> can anybody recommend how to properly configure newsyslog for log files that
> are constantly opened and written.  Some of my log files rotate but the new
> log file can never written to.

Read the newsyslog(8) manpage, in particular:

     path_to_pid_file
             This optional field specifies the file name to read to find the
             daemon process id.  If this field is present, a signal_number is
             sent the process id contained in this file.  This field must
             start with "/" in order to be recognized properly.

     signal_number
             This optional field specifies the signal number will be sent to
             the daemon process.  By default a SIGHUP will be sent.

Your process which is writing the log files must write its process ID
somewhere in a file for newsyslog to find it. Then after newsyslog has
renamed the file and created a new empty one of the same name it will
send the signal you specify, expecting it to close and re-open its log
files.

Files are written to by file descriptor, not by file name. So simply
changing the file name doesn't change the file being written to. Files
are opened by file name.

fstat(1) is your friend for finding who has what file open.

If it is a program you wrote and don't wish to bother with a signal()
handler then simply don't constantly leave your log files open. Open the
log file, write what you have to say, close the log file. Each and every
time. There is still a possibility of collision with newsyslog but that
won't be a problem if you do not compress the rotated file.

-- 
David Kelly N4HHE, dkelly at hiwaay.net
=====================================================================
The human mind ordinarily operates at only ten percent of its
capacity -- the rest is overhead for the operating system.


More information about the freebsd-questions mailing list