Zbigniew Szalbot wrote:

Matthew Seaman:

Correct. Although you may want to add '30' as the 8th field -- that means
'send signal 30 (SIGUSR1) to apache instead of SIGHUP' -- SIGUSR1 causes
apache to do a graceful restart rather than abruptly killing and restarting
everything: http://httpd.apache.org/docs/2.2/stopping.html

You'll need to experiment though -- if your user HTTP connections are long-lived, you can end up with apache appending data to a rotated logfile
that it still has an open file descriptor on.  The file will be unlinked
once the gzip compression has run.  Now, writing to an unlinked file is
allowed under Unix, but once that apache child process terminates and releases the descriptor the data will disappear into the ether, so you
can lose log entries.

Thank you very much Matthew! Just one final question. When the apache child process finally terminates, will apache start logging to a new log? Or will it be writing into the ether until it gets restarted?

Thanks again! I appreciate your help.

The restart process with apache is that all the child processes are
shutdown -- either straight away (for a plain restart) or once they've
finished their current bit of work (fora graceful restart). As the child
process shuts down, it closes all the file descriptors used for logging.

Ultimately the master process will respawn itself -- in the event of a graceful 
restart this may occur before all of the old child processes
have closed down.  I'm not sure if the master process actually logs anything 
much, but even if it doesn't this will similarly close and
then reopen all file descriptors.

The renewed master process then starts up a whole new set of child
processes, each of which will open up new logging connections.

Now, if logging direct to a file, apache will open the file by name.
As newsyslog has just moved away the old file and created a new file
with the appropriate name, this means that all log output from the
new apache processes will go into the new log file.

Which is what you want.



Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                 Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
                                                 Kent, CT11 9PW

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to