Log file timestamp

Hello,

I’m trying to figure out why my nginx access log timestamps are an hour
behind the actual time.
I’ve confirmed that the “date” and “hwclock” commands both return the
proper
values on the system and that the timezone is correct but the timestamps
in
the nginx logs are all an hour off.
I realize this may not be an Nginx problem but I’m not sure how else to
narrow down the possibilities.

Any insights are greatly appreciated.

RedHat el5 - 2.6.18-8.el5
nginx/0.6.29

Thanks,
-Jake

On Wed, Jun 18, 2008 at 02:10:37PM -0400, J Davis wrote:

RedHat el5 - 2.6.18-8.el5
nginx/0.6.29

This may be incorrectly set daylight saving time offset.
Could you show last line from access log and output of

date

and

date -u

?

I think you are on to something.

date: Wed Jun 18 15:23:03 EDT 2008
date -u: Wed Jun 18 19:23:05 UTC 2008
access.log: 18/Jun/2008:14:23:34 -0500

I made sure that my tzdata package was up to date and that
/etc/localtime
points to the correct zone at /usr/share/zoneinfo/America/New_York. I
then
gave nginx the HUP signal (not sure if that was necessary).

but the time stamps are still 1 hour behind.

-Jake

On Wed, Jun 18, 2008 at 03:51:37PM -0400, J Davis wrote:

but the time stamps are still 1 hour behind.
Could you build the program below and run it together with date and date
-u ?


#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include <time.h>
#include <stdio.h>

int
main()
{
time_t s;
struct tm t;

tzset();

s = time(NULL);

(void) localtime_r(&s, &t);

printf("%02d:%02d %d %d\n", t.tm_hour, t.tm_min, t.tm_isdst, 

timezone);

return 0;

}

Also could you send the output of nginx’s ./configure ?

Forgot this part…

./configure
checking for OS

  • Linux 2.6.18-8.el5 x86_64
    checking for C compiler … found
  • using GNU C compiler
  • gcc version: 4.1.2 20070626 (Red Hat 4.1.2-14)
    checking for gcc -pipe switch … found
    checking for gcc variadic macros … found
    checking for C99 variadic macros … found
    checking for unistd.h … found
    checking for inttypes.h … found
    checking for limits.h … found
    checking for sys/filio.h … not found
    checking for crypt.h … found
    checking for malloc.h … found
    checking for Linux specific features
    checking for epoll … found
    checking for sendfile() … found
    checking for sendfile64() … found
    checking for sys/prctl.h … found
    checking for prctl(PR_SET_DUMPABLE) … found
    checking for sched_setaffinity() … found
    checking for nobody group … found
    checking for poll() … found
    checking for /dev/poll … not found
    checking for kqueue … not found
    checking for crypt() … not found
    checking for crypt() in libcrypt … found
    checking for PCRE library … found
    checking for zlib library … found
    checking for int size … 4 bytes
    checking for long size … 8 bytes
    checking for long long size … 8 bytes
    checking for void * size … 8 bytes
    checking for uint64_t … found
    checking for sig_atomic_t … found
    checking for sig_atomic_t size … 4 bytes
    checking for socklen_t … found
    checking for in_addr_t … found
    checking for in_port_t … found
    checking for rlim_t … found
    checking for uintptr_t … uintptr_t found
    checking for system endianess … little endianess
    checking for size_t size … 8 bytes
    checking for off_t size … 8 bytes
    checking for time_t size … 8 bytes
    checking for setproctitle() … not found
    checking for pread() … found
    checking for pwrite() … found
    checking for strerror_r() … found but is not working
    checking for gnu style strerror_r() … found
    checking for localtime_r() … found
    checking for posix_memalign() … found
    checking for memalign() … found
    checking for sched_yield() … found
    checking for mmap(MAP_ANON|MAP_SHARED) … found
    checking for mmap("/dev/zero", MAP_SHARED) … found
    checking for System V shared memory … found
    checking for struct msghdr.msg_control … found
    checking for ioctl(FIONBIO) … found
    checking for struct tm.tm_gmtoff … found

Configuration summary

  • threads are not used
  • using system PCRE library
  • OpenSSL library is not used
  • md5 library is not used
  • sha1 library is not used
  • using system zlib library

nginx path prefix: “/usr/local/nginx”
nginx binary file: “/usr/local/nginx/sbin/nginx”
nginx configuration prefix: “/usr/local/nginx/conf”
nginx configuration file: “/usr/local/nginx/conf/nginx.conf”
nginx pid file: “/usr/local/nginx/logs/nginx.pid”
nginx error log file: “/usr/local/nginx/logs/error.log”
nginx http access log file: “/usr/local/nginx/logs/access.log”
nginx http client request body temporary files:
“/usr/local/nginx/client_body_temp”
nginx http proxy temporary files: “/usr/local/nginx/proxy_temp”
nginx http fastcgi temporary files: “/usr/local/nginx/fastcgi_temp”

Thanks!

here’s the output…
07:58 1 18000
date: Thu Jun 19 07:58:26 EDT 2008
date -u: Thu Jun 19 11:58:27 UTC 2008

-Jake

On Thu, Jun 19, 2008 at 08:08:32AM -0400, J Davis wrote:

checking for struct tm.tm_gmtoff … found

Well, could you built a new program below and run it with date’s again ?


#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include <time.h>
#include <stdio.h>

int
main()
{
time_t s;
struct tm t;

tzset();

s = time(NULL);

(void) localtime_r(&s, &t);

printf("%02d:%02d %d %d\n", t.tm_hour, t.tm_min, t.tm_isdst, 

t.tm_gmtoff);

return 0;

}

On Thu, Jun 19, 2008 at 09:08:07AM -0400, J Davis wrote:

09:07 1 -14400
date: Thu Jun 19 09:07:04 EDT 2008
date -u: Thu Jun 19 13:07:06 UTC 2008

Now it shows correct time.
Could you make nginx dummy online upgrade ?

kill -USR2 cat nginx.pid
sleep 3
kill -QUIT cat nginx.pid.oldbin

nginx calls tzset() in master process on start only.
Probably your timezone setting was incorrect before.

09:07 1 -14400
date: Thu Jun 19 09:07:04 EDT 2008
date -u: Thu Jun 19 13:07:06 UTC 2008

-Jake

For some reason I get this in the error log when giving nginx the -USR2
sginal.

2008/06/19 08:50:31 [crit] 32282#0: the changing binary signal is
ignored:
you should shutdown or terminate before either old or new binary’s
process

On Thu, Jun 19, 2008 at 09:53:20AM -0400, J Davis wrote:

For some reason I get this in the error log when giving nginx the -USR2
sginal.

2008/06/19 08:50:31 [crit] 32282#0: the changing binary signal is ignored:
you should shutdown or terminate before either old or new binary’s process

If you never did online upgrade before, this may mean that you run nginx
under daemontools/etc. Thus online upgrade is not available in this
case.

That was it exactly. Times are correct now.
Thank you very much for the assistance.

-Jake