[CLUE-Tech] Setting System Time

marcus at tuells.org marcus at tuells.org
Thu Jul 4 08:43:01 MDT 2002


>In short, date shows the correct time, but files are created with 
>timestamps 6 hours in the future (when localtime is MDT).
...
>It seems that the kernel has become schizophrenic about the time, 
>reporting one to date and another to ls.  I don't know offhand how to 
>see the raw time on an inode to confirm whether the timestamp is wrong 
>or perhaps just a bug in ls (or date).

The kernel doesn't know a thing about timezones...  All times are in
seconds from 1 Jan 1970 GMT.  The date and ls programs convert this to/from
local time (with the help of the libc localtime() and friends).

My first guess would be that date and ls are using different versions of
libc with differing ideas of where to get the local timezone from.  You
can force the timezone with the TZ environment variable and try each
command to see what happens:

	TZ=MST7MDT date
	TZ=MST7MDT ls [file]

If the commands don't agree with this invocation, then it needs deeper
thought.  If they *do* agree, then the command that changed its mind
isn't picking up the timezone info correctly.

Verify which "date" and "ls" you are actually executing, perhaps you
have a funny version in your path by mistake:

     which date
     which ls

If they both look reasonable, then check if they both link against the
same version of libc:

     ldd /bin/date
     ldd /bin/ls

On my system, they both output a line with:

   libc.so.6 => /lib/libc.so.6

My guess is that you will find that you are running a version of ls that
links to a different libc and that libc doesn't correctly determine the
default timezone and defaults to GMT (6 hours ahead of MDT).

marcus hall



More information about the clue-tech mailing list