Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #256313

Re: differences between hwclock <-> date due to time zone issues? ...

From Stefan Monnier <monnier@iro.umontreal.ca>
Newsgroups linux.debian.user
Subject Re: differences between hwclock <-> date due to time zone issues? ...
Date 2023-03-23 23:10 +0100
Message-ID <GcBi9-eC0I-7@gated-at.bofh.it> (permalink)
References <GcAYN-eBEG-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


>  I am using this (yes, visually cr@ppy ;-)) code snippet to set back
> the time 5 hours. hwclock tells me it worked fine but the terminal
> windows opened before and after running hwclock still give me the
> "old" time setting?

The hardware clock is an "external" device which the Linux kernel
typically uses in very limited ways:
1- it reads it at boot to figure out what is the current time to
   initialize the system's own time.
2- it adjusts it every once in a while when the system's time is
   presumed to be more precise (because it's using NTP).

If you want to change the system's time, then change the system's time,
not the hardware clock.

To change the system's time, use `date` (see `man date` for the format
of its arguments).

But changing the system's time is very rarely a good idea.

If you want to change the time based on timezone issues, then change the
*timezone* rather than the time this way your running applications won't
be subjected to time travel, which tends to cause all kinds of odd
behaviors because suddenly the timer that was supposed to fire after
a handful of seconds suddenly waits 5h, or the timeout that should only
fire when there's really no answer after 2min fires right away because
it thinks 5h have passed.  Oh, and connections on the internet may fail
when your machine's time is to too far out of sync (and 5h *is* far),
since some authentication algorithms rely on time constraints.

Note that the timezone is not a system-wide setting.  Every process can
use its own timezone, e.g. by setting the `TZ` environment variable.
Try for example `TZ=UTC date` and then `TZ=Pacific/Samoa date`.
Browse /usr/share/zoneinfo/ to see the list of timezones your system
knows about.


        Stefan

Back to linux.debian.user | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

differences between hwclock <-> date due to time zone issues? ... Albretch Mueller <lbrtchx@gmail.com> - 2023-03-23 22:50 +0100
  Re: differences between hwclock <-> date due to time zone issues? ... Stefan Monnier <monnier@iro.umontreal.ca> - 2023-03-23 23:10 +0100
  Re: differences between hwclock <-> date due to time zone issues? ... Cindy Sue Causey <butterflybytes@gmail.com> - 2023-03-23 23:10 +0100
    Re: differences between hwclock <-> date due to time zone issues? ... Cindy Sue Causey <butterflybytes@gmail.com> - 2023-03-23 23:30 +0100
  Re: differences between hwclock <-> date due to time zone issues? ... David Wright <deblis@lionunicorn.co.uk> - 2023-03-23 23:50 +0100
  Re: differences between hwclock <-> date due to time zone issues? ... Andy Smith <andy@strugglers.net> - 2023-03-24 15:50 +0100
    Re: differences between hwclock <-> date due to time zone issues? ... Albretch Mueller <lbrtchx@gmail.com> - 2023-03-24 18:20 +0100
      Re: differences between hwclock <-> date due to time zone issues? ... Greg Wooledge <greg@wooledge.org> - 2023-03-24 22:50 +0100
        Re: differences between hwclock <-> date due to time zone issues? ... Stefan Monnier <monnier@iro.umontreal.ca> - 2023-03-24 23:00 +0100
          Re: differences between hwclock <-> date due to time zone issues? ... Greg Wooledge <greg@wooledge.org> - 2023-03-24 23:10 +0100
            Re: differences between hwclock <-> date due to time zone issues? ... Stefan Monnier <monnier@iro.umontreal.ca> - 2023-03-25 00:20 +0100
              Re: differences between hwclock <-> date due to time zone issues? ... Albretch Mueller <lbrtchx@gmail.com> - 2023-03-25 01:10 +0100
                Re: differences between hwclock <-> date due to time zone issues? ... Max Nikulin <manikulin@gmail.com> - 2023-03-25 04:20 +0100
                Re: differences between hwclock <-> date due to time zone issues? ... Albretch Mueller <lbrtchx@gmail.com> - 2023-03-25 04:50 +0100
                Re: differences between hwclock <-> date due to time zone issues? ... Max Nikulin <manikulin@gmail.com> - 2023-03-25 06:00 +0100
                Re: differences between hwclock <-> date due to time zone issues? ... Max Nikulin <manikulin@gmail.com> - 2023-03-25 09:00 +0100
              Re: differences between hwclock <-> date due to time zone issues? ... David Wright <deblis@lionunicorn.co.uk> - 2023-03-25 05:30 +0100
      Re: differences between hwclock <-> date due to time zone issues? ... David Wright <deblis@lionunicorn.co.uk> - 2023-03-25 05:30 +0100
        Re: differences between hwclock <-> date due to time zone issues? ... Felix Miata <mrmazda@earthlink.net> - 2023-03-25 05:50 +0100

csiph-web