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

Re: system time - thank you



Hi !

and Thank you Bob for the kind answer. It was my mistake not to read the documentation in depth. So your suggestion was a great help. Now I understand the results of hwclock,
Just to make it clear to everyone interested - also in the future :

1 - 'hwclock --show' : reads by its own the content of '/etc/adjtime' (if this file does not exist the dafault(*) is localtime) to understand if the RTC is in UTC or LOCALTIME than it shows, after a conversion if necessary, the time in localtime.

2 - ' hwclock --show --utc' : _I_ explicitly_ say - no matter if this is the truth or not - to hwclock that the RTC is in UTC, than it shows the time got from the hardware, after a conversion.

3 - 'hwclock --show --localtime' : _I explicitly_ say - no matter if this is the truth or not - to hwclock that the RTC is in LOCALTIME, than it shows the time got from the hardware,without a conversion.

By the way a question arises: why the default in (*) is localtime ... It seems that when I first wrote the post the system '/etc/default/rcS' has been configured with 'UTC=yes' ... mmm ... odd, isnt it ? ;)

cheers and Thank u again!

daniele



Bob Proulx wrote:
daniele pendenza wrote:
So I think this is the general picture :
1 - when the system starts the value of the system time is defined taking into account the value of the RTC time the value of the UTC constant retrived at startup and the timezone information. 2 - when the system is up and running the system time is "the time that matters" - as you said - and, when requested, it is presented to users after the "timezone shift" eventually. 3 - when the system is shutdown the system time is _saved_ after calculations based on the same informations as in line 1.

All correct.

If all that I wrote is correct : why the command ' hwclock --show --localtime' shows me the UTC time and 'hwclock --show --utc' shows me the localtime ?

The --utc and --localtime options are not to affect the display but to
configure how hwclock reads time from the hardware clock.  Those
options tell hwclock whether the hardware clock is kept in UTC or in
localtime.  The --show always displays in localtime.

       --show Read the Hardware Clock and print the time on Standard
              Output.  The time shown is always in local time, even if
              you keep your Hardware Clock in Coordinated Universal
              Time.  See the --utc option.

I set up UTC=yes and the timezone is Europe/Rome and I don't have windows... uh

Then hwclock --utc would be the correct option for you since the
hardware clock is set to UTC.  If you use --localtime then hwclock
will wrongy think that the hardware clock is in local time and apply
an undesired correction factor.

Generally userland applications should use date instead of hwclock to
get time information.  The hardware clock interface will be slower and
more resource intensive because this is through the kernel and from
the hardware.  Plus IIRC while doing this hardware clocks may skip
clock tick interrupts.  Plus the hardware clock is not corrected for
drift.  The system clock should be running an NTP daemon and would
always have a corrected value.  Because of these things it is almost
always better to use the system clock over the hardware clock.

Bob



Reply to: