log size handling
Matthew Seaman
m.seaman at infracaninophile.co.uk
Fri Jul 18 11:26:15 UTC 2008
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 258 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20080718/389bc4d7/signature.pgp
More information about the freebsd-questions
mailing list