1 |
Am 03.08.2011 18:40, schrieb Michael Mol: |
2 |
> On Wed, Aug 3, 2011 at 12:31 PM, Jarry <mr.jarry@×××××.com> wrote: |
3 |
>> But is it actually necessary to do it? I mean everything between |
4 |
>> postrotate-endscript is done after the log file has been rotated. |
5 |
> |
6 |
> The log file has been moved, but Apache still holds open the file |
7 |
> descriptor to the old log file--it will continue writing to that file, |
8 |
> even under its new name. |
9 |
> |
10 |
>> So I do not understand why at that time apache must be reloaded. |
11 |
> |
12 |
> The reload causes Apache to close the file descriptor, and then open |
13 |
> the file again. Since it *opens* the file by name, it will start with |
14 |
> a fresh log file. |
15 |
> |
16 |
>> |
17 |
>> Moreover, because of that apache-reloading apc was emptied so it |
18 |
>> takes again some time till all php-scripts are in cache again... |
19 |
> |
20 |
> What you really want is for the logrotate script to ask Apache to |
21 |
> flush its logs and reopen the file. I don't know offhand if Apache has |
22 |
> a way to do that, short of a graceful restart. |
23 |
> |
24 |
|
25 |
I'm not aware of such an option (doesn't mean it doesn't exist, though). |
26 |
The cleanest solution I can think of is to order apache to send its logs |
27 |
to syslog. [1] shows how to do this. Of course you still have to reload |
28 |
syslog-ng when you rotate the log files but apache itself can keep running. |
29 |
|
30 |
[1] http://oreilly.com/pub/a/sysadmin/2006/10/12/httpd-syslog.html |
31 |
|
32 |
Hope this helps, |
33 |
Florian Philipp |