You are not logged in.

#1 2011-08-11 20:00:36

nTia89
Banned
From: varese, italy
Registered: 2008-12-22
Posts: 1,230

time updater - ntp and hwclock explanations

hi to everybody,

i have confusion about time updater:

i have set the time, timezone and related in rc.conf and the time is right
however after 1 month,more or less, my time is wrong.... so i need and automated time updater
i read in our archwiki and i've found NTP
reading NTP, i'm confusing about HWCLOCK daemon and NTP daemon

someone can explain me what i need for updating correctly my time (UTC - hardware clock) ?

thanks


+pc: custom | AMD Opteron 175 | nForce4 Ultra | 2GB ram DDR400 | nVidia 9800GT 1GB | ArchLinux x86_64 w/ openbox
+laptop: Apple | MacBook (2,1) | 2GB ram | Mac OS X 10.4 -> DIED
+ultrabook: Dell | XPS 13 (9343) | 8GB ram | 256GB ssd | FullHD display | Windows 8.1 64bit ArchLinux x86_64 w/ Gnome

Offline

#2 2011-08-11 21:38:26

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: time updater - ntp and hwclock explanations

hwclock is for when you don't use NTP. If in doubt, disable hwclock, install and run ntpd instead.

Offline

#3 2011-08-11 21:56:43

lukaszan
Member
Registered: 2011-05-05
Posts: 117

Re: time updater - ntp and hwclock explanations

I thought hwclock was for synchronising hardware clock with OS clock, and NTP was synchronising OS clock with internet.

Offline

#4 2011-08-11 21:59:20

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: time updater - ntp and hwclock explanations

lukaszan wrote:

I thought hwclock was for synchronising hardware clock with OS clock, and NTP was synchronising OS clock with internet.

Both tools are used for the same general purpose: to keep your time accurate. With hwclock you can set your OS time to your hardware time and vice versa.

Offline

#5 2011-08-12 04:43:48

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,774

Re: time updater - ntp and hwclock explanations

In my mind, hwclock is critical because it is available at boot to initialize the system clock.  NTP then (when available) servos the system time to internet time and fine tunes the system so that time remains accurate when NTP goes away.  Finally, at shutdown, the accurate system time is put back to the hardware clock so that it is as accurate as possible at the next startup.

They really need to work together


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#6 2011-08-12 05:54:06

siriusb
Member
From: Hungary
Registered: 2010-01-01
Posts: 422

Re: time updater - ntp and hwclock explanations

From wiki: ntpd sets 11 minute mode, which syncs the system clock to hardware every 11 minutes. The hwclock daemon measures hardware clock drift and syncs it, which conflicts with ntpd.

So ntp will sync time with hardware clock periodically without hwclock running as daemon.

Offline

#7 2011-08-12 06:30:30

swanson
Member
From: Sweden
Registered: 2011-02-05
Posts: 759

Re: time updater - ntp and hwclock explanations

One solution for a desktop user is to add this to rc.local:

ntpd -qg &
hwclock --systohc

ntpd sets the time and quits then the hwclock command adjusts the time. No daemons running from rc.conf. Of course, for a 24/7 server this is not the best, but for a desktop it's good enuogh.

Last edited by swanson (2011-08-12 06:30:59)

Offline

#8 2011-08-12 07:50:59

lukaszan
Member
Registered: 2011-05-05
Posts: 117

Re: time updater - ntp and hwclock explanations

For 24/7 desktop: ntpdate in cron.hourly.

I'll probably get slated, but works a treat for me.

Offline

#9 2011-08-12 09:36:16

nTia89
Banned
From: varese, italy
Registered: 2008-12-22
Posts: 1,230

Re: time updater - ntp and hwclock explanations

because my hardware clock isn't enough precise, i need a tool that retrieve time from another but precise source and after a tool that write the time into hardware clock

by what i've read hwclock ONLY save time from/to system/hardware clock AND isn't able to retrieve correct time
instead this feature is present in NTP

is right ? have i well understand ?


+pc: custom | AMD Opteron 175 | nForce4 Ultra | 2GB ram DDR400 | nVidia 9800GT 1GB | ArchLinux x86_64 w/ openbox
+laptop: Apple | MacBook (2,1) | 2GB ram | Mac OS X 10.4 -> DIED
+ultrabook: Dell | XPS 13 (9343) | 8GB ram | 256GB ssd | FullHD display | Windows 8.1 64bit ArchLinux x86_64 w/ Gnome

Offline

#10 2011-08-12 09:38:41

siriusb
Member
From: Hungary
Registered: 2010-01-01
Posts: 422

Re: time updater - ntp and hwclock explanations

Offline

#11 2011-08-12 09:58:11

nTia89
Banned
From: varese, italy
Registered: 2008-12-22
Posts: 1,230

Re: time updater - ntp and hwclock explanations

so, as swanson says, i can use this combination of command:

ntpd -qg &
hwclock --systohc

first for retrieving correct time
second for saving it into my hardware clock

for my use i can put their into the cron.hourly directory

is right ?


+pc: custom | AMD Opteron 175 | nForce4 Ultra | 2GB ram DDR400 | nVidia 9800GT 1GB | ArchLinux x86_64 w/ openbox
+laptop: Apple | MacBook (2,1) | 2GB ram | Mac OS X 10.4 -> DIED
+ultrabook: Dell | XPS 13 (9343) | 8GB ram | 256GB ssd | FullHD display | Windows 8.1 64bit ArchLinux x86_64 w/ Gnome

Offline

#12 2011-08-12 09:59:37

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: time updater - ntp and hwclock explanations

only putting ntpd in your DAEMONS array works fine for me. the daemon connects to the internet and gets the correct time. Why do you need to create a cron job?


if you are using hwclock to simply correct for the incorrect time in hardware clock, have a look at Time skew in the wiki. Maybe all you need to do is delete hwclock's adjtime file. It will be recreated and you probably won't have issues with the hardware clock going haywire.


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#13 2011-08-12 10:09:39

Meyithi
Member
From: Wirral, UK
Registered: 2009-06-21
Posts: 550
Website

Re: time updater - ntp and hwclock explanations

It's right there in the wiki

ntpd sets 11 minute mode, which syncs the system clock to hardware every 11 minutes. The hwclock daemon measures hardware clock drift and syncs it, which conflicts with ntpd.


The mind roams more freely in empty rooms.
dwm - colours - ncmpcpp - system
irc://irc.freenode.net:meyithi

Offline

#14 2011-08-12 12:13:33

nTia89
Banned
From: varese, italy
Registered: 2008-12-22
Posts: 1,230

Re: time updater - ntp and hwclock explanations

Inxsible wrote:

only putting ntpd in your DAEMONS array works fine for me. the daemon connects to the internet and gets the correct time. Why do you need to create a cron job?


if you are using hwclock to simply correct for the incorrect time in hardware clock, have a look at Time skew in the wiki. Maybe all you need to do is delete hwclock's adjtime file. It will be recreated and you probably won't have issues with the hardware clock going haywire.

because putting in daemon's array, every time i boot, ntp synchronize the time

instead if i put command in cron, it will be executed, so ntp synchronize, only once at month for example , not every time i boot....


+pc: custom | AMD Opteron 175 | nForce4 Ultra | 2GB ram DDR400 | nVidia 9800GT 1GB | ArchLinux x86_64 w/ openbox
+laptop: Apple | MacBook (2,1) | 2GB ram | Mac OS X 10.4 -> DIED
+ultrabook: Dell | XPS 13 (9343) | 8GB ram | 256GB ssd | FullHD display | Windows 8.1 64bit ArchLinux x86_64 w/ Gnome

Offline

#15 2011-08-12 12:16:06

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: time updater - ntp and hwclock explanations

nTia89 wrote:
Inxsible wrote:

only putting ntpd in your DAEMONS array works fine for me. the daemon connects to the internet and gets the correct time. Why do you need to create a cron job?


if you are using hwclock to simply correct for the incorrect time in hardware clock, have a look at Time skew in the wiki. Maybe all you need to do is delete hwclock's adjtime file. It will be recreated and you probably won't have issues with the hardware clock going haywire.

because putting in daemon's array, every time i boot, ntp synchronize the time

instead if i put command in cron, it will be executed, so ntp synchronize, only once at month for example , not every time i boot....

I'm with Inxsible here, check your adjtime file.

Offline

#16 2011-08-12 12:16:07

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: time updater - ntp and hwclock explanations

nTia89 wrote:
Inxsible wrote:

only putting ntpd in your DAEMONS array works fine for me. the daemon connects to the internet and gets the correct time. Why do you need to create a cron job?


if you are using hwclock to simply correct for the incorrect time in hardware clock, have a look at Time skew in the wiki. Maybe all you need to do is delete hwclock's adjtime file. It will be recreated and you probably won't have issues with the hardware clock going haywire.

because putting in daemon's array, every time i boot, ntp synchronize the time

instead if i put command in cron, it will be executed, so ntp synchronize, only once at month for example , not every time i boot....

And the problem with it synchronizing on every boot is ........?


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#17 2011-08-12 12:32:42

nTia89
Banned
From: varese, italy
Registered: 2008-12-22
Posts: 1,230

Re: time updater - ntp and hwclock explanations

yes, only because i need to update time not every time i boot.....

and adjtime is executed every hour, right, but if hwclock daemon isn't running it doesn't do anything

so, excluding my idea to add a cron, i need only to put "ntpd" in my daemon array ? then, adjtime cron take care of saving software clock (because ntp set only the software clock) in the hardware clock ?


+pc: custom | AMD Opteron 175 | nForce4 Ultra | 2GB ram DDR400 | nVidia 9800GT 1GB | ArchLinux x86_64 w/ openbox
+laptop: Apple | MacBook (2,1) | 2GB ram | Mac OS X 10.4 -> DIED
+ultrabook: Dell | XPS 13 (9343) | 8GB ram | 256GB ssd | FullHD display | Windows 8.1 64bit ArchLinux x86_64 w/ Gnome

Offline

#18 2011-08-12 12:35:09

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: time updater - ntp and hwclock explanations

Please post the output of

cat /var/lib/hwclock/adjtime

Offline

#19 2011-08-12 12:37:41

lukaszan
Member
Registered: 2011-05-05
Posts: 117

Re: time updater - ntp and hwclock explanations

Inxsible wrote:

only putting ntpd in your DAEMONS array works fine for me. the daemon connects to the internet and gets the correct time. Why do you need to create a cron job?

I never got it to work with Arch package. It seemed the daemon worked as a server rather then a client. I ended up installing vanilla NTP and adding a 1-liner into cron.hourly... Simples.

Offline

#20 2011-08-12 13:09:54

Google
Member
From: Mountain View, California
Registered: 2010-05-31
Posts: 484
Website

Re: time updater - ntp and hwclock explanations

swanson wrote:

One solution for a desktop user is to add this to rc.local:

ntpd -qg &
hwclock --systohc

ntpd sets the time and quits then the hwclock command adjusts the time. No daemons running from rc.conf. Of course, for a 24/7 server this is not the best, but for a desktop it's good enuogh.

This FINALLY fixed mine. Is there any way to make this fix the system clock faster?

Offline

#21 2011-08-12 13:11:56

nTia89
Banned
From: varese, italy
Registered: 2008-12-22
Posts: 1,230

Re: time updater - ntp and hwclock explanations

karol wrote:

Please post the output of

cat /var/lib/hwclock/adjtime
6.948322 1313062939 0.000000
1313062939
UTC

+pc: custom | AMD Opteron 175 | nForce4 Ultra | 2GB ram DDR400 | nVidia 9800GT 1GB | ArchLinux x86_64 w/ openbox
+laptop: Apple | MacBook (2,1) | 2GB ram | Mac OS X 10.4 -> DIED
+ultrabook: Dell | XPS 13 (9343) | 8GB ram | 256GB ssd | FullHD display | Windows 8.1 64bit ArchLinux x86_64 w/ Gnome

Offline

#22 2011-08-12 13:14:56

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: time updater - ntp and hwclock explanations

nTia89 wrote:
karol wrote:

Please post the output of

cat /var/lib/hwclock/adjtime
6.948322 1313062939 0.000000
1313062939
UTC

Looks fine. If the first number in the first line gets too high, your clock will show the wrong time. You can check the file e.g. in a month.

Offline

#23 2011-08-12 13:31:47

nTia89
Banned
From: varese, italy
Registered: 2008-12-22
Posts: 1,230

Re: time updater - ntp and hwclock explanations

now my question is:

how many times ntpd retrieve the correct time from servers ?


+pc: custom | AMD Opteron 175 | nForce4 Ultra | 2GB ram DDR400 | nVidia 9800GT 1GB | ArchLinux x86_64 w/ openbox
+laptop: Apple | MacBook (2,1) | 2GB ram | Mac OS X 10.4 -> DIED
+ultrabook: Dell | XPS 13 (9343) | 8GB ram | 256GB ssd | FullHD display | Windows 8.1 64bit ArchLinux x86_64 w/ Gnome

Offline

Board footer

Powered by FluxBB