Twitter Updates

    follow me on Twitter

    G-AVLN in front of her home

    G-AVLN in front of her home

    Mostly Unix and Linux topics. But flying might get a mention too.

    Monday, October 15, 2007

    No access to ntp source?

    When you install Linux on a PC, you may find that the hardware clock enforced the time. Normally, you would use the ntpd (network time protocol daemon) to synchronise the system (software) time with a selection of external sources.

    However, what if you are not connected, or for some reason just don't have access to time servers (for example the ntpd port 123 is blocked)?

    Well, unless you need to maintain a precise time (in which case you still need to find access to a reliable source), you can just use the good old date command and inform the hardware clock of the change.

    # date --utc 101517052007.00

    will update the system (software) clock and set the current time and date to: Oct 15 18:05:00 BST 2007.

    The only problem is that system clock doesn't run when your machine is powered off. What does continue to run is the hardware clock. It ticks forever. External power present or not. Because on start-up the hardware clock is used, you need to flush the system date into the hardware clock, and as long as the hardware clock is accurate enough, your newly adjusted time will be persistent over reboots.

    Use the hwclock tool to achieve this:

    # hwclock --systohc

    Do remember, though: this is 'quick and dirty'. If you require consistent and accurate time keeping, you need to synchronise the system clock with an external source...

    1 comment:

    Semele said...

    Interesting to know.

    Blog Archive