You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Lucid <lu...@secret.org> on 1996/06/13 00:33:41 UTC
Timezone Hack for rotatelogs
Eventually we should re-write this as a module
because it doesn't work very well for virtuial hosts
Bill Morris
memetic Design
BMorris@memetic.com
800-647-3597
*** rotatelogs.c.old Wed Jun 12 17:45:20 1996
--- rotatelogs.c Wed Jun 12 18:19:31 1996
***************
*** 2,15 ****
Simple program to rotate Apache logs without having to kill the server.
! Contributed by Ben Laurie <be...@algroup.co.uk>
! TimeZone Hack by Bill Morris <bm...@memetic.com> 12 Jun 1996
*/
#define BUFSIZE 65536
#define MAX_PATH 1024
+ #define TZ_OFFSET -14400
+ /* Offset of your timezone in seconds */
+ /*------------------------------------*/
+ /* X = Offset in Hours * 3600 */
+ /* GMT 0 */
+ /* EST -14400 Daylight Savings Time */
+ /* EST -18000 Normal */
+ /* PST -25200 Daylight Savings Time */
+ /* PST -28800 Normal */
#include <stdio.h>
#include <time.h>
***************
*** 52,65 ****
if(nRead < 0)
if(errno != EINTR)
exit(4);
! if(nLogFD >= 0 && (time(NULL) >= tLogEnd || nRead < 0))
{
close(nLogFD);
nLogFD=-1;
}
if(nLogFD < 0)
{
! time_t tLogStart=(time(NULL)/tRotation)*tRotation;
sprintf(buf2,"%s.%d",szLogRoot,tLogStart);
tLogEnd=tLogStart+tRotation;
nLogFD=open(buf2,O_WRONLY|O_CREAT|O_APPEND,0666);
--- 60,73 ----
if(nRead < 0)
if(errno != EINTR)
exit(4);
! if(nLogFD >= 0 && (time(NULL)-TZ_OFFSET >= tLogEnd || nRead < 0))
{
close(nLogFD);
nLogFD=-1;
}
if(nLogFD < 0)
{
! time_t tLogStart=(time(NULL)/tRotation)*tRotation-TZ_OFFSET;
sprintf(buf2,"%s.%d",szLogRoot,tLogStart);
tLogEnd=tLogStart+tRotation;
nLogFD=open(buf2,O_WRONLY|O_CREAT|O_APPEND,0666);