Zbigniew Szalbot wrote:
Hello,

Matthew Seaman:
Do I have to rotate them myself via a script in crontab?

There are several ways to do this.  Here's three in addition to the
script that someone else just posted:

 * Use the 'G' option to newsyslog.  'G' says that the filename
   field of newsyslog.conf actually contains a shell globbing pattern
   (wildcard) and files matching that should be rotated and compressed.

So would something like this work?

/var/log/site-*.log         644  12    *    $M1D0 GZC /var/run/httpd.pid

Many thanks in advance!

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.

        Cheers,

        Matthew

--
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