Re: Re: Apache 2.2, rotatelogs.exe, and Windows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Sep 15, 2007, at 8:30 AM, Mark A. Craig wrote:

Nothing? No one has ever used rotatelogs.exe? Well, surely all you pros out there are rotating your companies' logs somehow... what and how are you doing it, and is it something I can use?

Rotatelogs should once again be usable as of 2.2.7. Before, the brokenness lay in the fact that it would leak stale rotatelogs.exe processes and cmd.exe shells upon server stop, start, restart or child process recycling (like crashes). Your config file problem is likely just that: a config file problem. Your config files should be ASCII, and there should be no need to edit them with anything more sophisticated than Notepad.

I have the following invocation of rotatelogs commented out in one of my configurations:

CustomLog "|d:/httpd-2.2.3-ssl/bin/rotatelogs.exe d:/cedserver/logs/ access-%Y-%m-%d.log 86400 -420" common

Note 1) forward slashes 2) no spaces in the paths (perhaps you can do that with careful quoting but I didn't have the patience" 3) 24 * 60 * 60 == 86400 seconds in a day (not a week like another respondent seems to think) and -420 is 7 timezones west of GMT, your mileage may vary.

The above is commented out though because I haven't upgraded to 2.2.7 yet. At this point I have a Perl script that I need to hang in the Windows Scripting Host, that does the following:

1) Move the old log out of the way
2) Give httpd a soft restart by calling:

my $command = "\"$httpd\" -d \"$ServerRoot\" -n $servicename -k restart";
   my $out = `$command`;

3) Zip up the old logfiles

Of course I have set $httpd, $ServerRoot and $servicename beforehand. The script also performs log analysis, but that's outside the scope of this discussion.

This approach has the following advantages over other procedures suggested in this thread:

1) No service interruption: net stop Apache2.2 causes the server to
   become unavailable (obviously) becasuse the process is shut down.
   This also happens ungracefully, so anyone currently accessing your
   server is confronted with errors
2) No lost log entries: by moving the log files out of the way, Apache
will keep writing to the open filehandles. Only when it is restarted
   will it open its new log files, without interruption in logging.
   Zipping up the logfiles and overwriting them with empty files leaves
   a hiatus in which you may lose log entries.

Determining the name of the old logfiles, and the archived files, is left as an exercise for the reader. Of course you can do this in any scripting language as long as you can call a command line program.

S.

--
Sander Temme
sctemme@xxxxxxxxxx
PGP FP: 51B4 8727 466A 0BC3 69F4  B7B8 B2BE BC40 1529 24AF



Attachment: smime.p7s
Description: S/MIME cryptographic signature


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux