[mdlug] Can the date stamp on a file be ahead of the clock

Raymond McLaughlin driveray at ameritech.net
Thu Sep 6 15:23:13 EDT 2007


R. Kannan wrote:
> Hi,
> 
> I am seeing a puzzling behavior in a linux machine at work. 
> See the series of commands and the responses below
> 
> 
> kez at vision->uname -a
> Linux vision 2.6.16.21-0.8-smp #1 SMP Mon Jul 3 18:25:39 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux
> kez at vision->touch tt1
> kez at vision->ls -l tt1
> -rw-r--r-- 1 kez hks 0 2007-09-06 14:49 tt1
> kez at vision->date
> Thu Sep  6 14:42:16 EDT 2007


Linux, and probably other unixes, keeps a system clock separate from the
hardware clock. The "hardware clock" command gives more information:
    ->/sbin/hwclock
or, better yet, to get (near) simultaneous reading of the two clocks
stack two commands on one line:
    ->/sbin/hwclock; date

In the following series of commands you see that I started out with
(more or less) synchronized clocks, changed one and examined the effect
on time stamps:

    pts/3 # hwclock;date
    Thu Sep  6 15:05:33 2007  -0.585800 seconds
    Thu Sep  6 15:05:32 EDT 2007
    pts/3 # date 09061515
    Thu Sep  6 15:15:00 EDT 2007
    pts/3 # hwclock;date
    Thu Sep  6 15:06:12 2007  -0.305832 seconds
    Thu Sep  6 15:15:03 EDT 2007
    pts/3 # touch foo
    pts/3 # ls -l foo
    -rw-r--r--  1 root root 0 Sep  6 15:15 foo
It seems that, on my system at least, the hardware clock is used for
file system time stamps.

I've read the relevant man pages repeatedly and still don't really see
the point of keeping two different clocks. I just keep mine
synchronized. First I use the date command to set the system clock, then
I run (as root of course):
    ->hwclock --systohc

I hope this helps
Raymond McLaughlin







More information about the mdlug mailing list