[opensuse] adjtime in openSUSE 11.2
Hello: My system clock tends to stray (1-2 minutes within a week, or so) So far I adjusted the time manually using the command: # sntp -r ntp1.ptb.de then setting hwclock # hwclcok --systohc I would like the system automatically set/keep the time. I also discovered that there is no /etc/adjtime on my system. Is that normal? Where could I find a decent description on how to use 1) adjtime method for keeping time, or 2) sntp in case when the system is turned off and on frequently and is connected to the net occasionally only. Thanks, Istvan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Istvan Gabor said the following on 02/19/2011 07:12 AM:
Hello:
My system clock tends to stray (1-2 minutes within a week, or so) So far I adjusted the time manually using the command: # sntp -r ntp1.ptb.de then setting hwclock # hwclcok --systohc
I would like the system automatically set/keep the time. I also discovered that there is no /etc/adjtime on my system. Is that normal?
Where could I find a decent description on how to use 1) adjtime method for keeping time, or 2) sntp in case when the system is turned off and on frequently and is connected to the net occasionally only.
The obvious answer to "where" is "have you googled?" But a more practical answer starts with "how have you set up date and time with YAST?" I see a setting for turning NTP on and configuring it. Start with yast -> system -> date and time You get a graphic of a map; set your timezone. Bottom right it says whether NTP is configured or not. Click the "Change" button. You get a new dialogue box "Change Date And time" There you can set the NTP service. If you run the daemon then it should start on each boot (or you could do some /etc/rc???? stuff to do a NTP one off on boot) and keep your clock synchronised. The "configure" button lets you set up the NTP daemon with alternate time servers. You may have to google to find some alternative time servers. If you don't like any of that you can run sntp from cron, or better, 'ntpd -q' Since I run ntpd I don't worry about the hardware clock. So long as I have a network connection, boot will run ntpd of some form and set the system clock, and its the system clock that matters. If I don't have a connection, yes it all falls back to the hardware clock, but so long as that isn't WAY out I have to face the priority of not having a network connection for my laptop. If I loose a connection for my 'desktop' during the day, then MAYBE the clock will drift, but that is a lesser problem than the loss of the connection! The other part of your question - adjtime - presupposes that you are reliant SOLELY on the hardware clock. If you read the manual page for HWCLOCK it says <quote> The Adjust Function The Hardware Clock is usually not very accurate. However, much of its inaccuracy is completely predictable - it gains or loses the same amount of time every day. This is called systematic drift. hwclock's "adjust" function lets you make systematic corrections to correct the systematic drift. It works like this: hwclock keeps a file, /etc/adjtime, that keeps some historical information. This is called the adjtime file. Suppose you start with no adjtime file. You issue a hwclock --set command to set the Hardware Clock to the true current time. Hwclock creates the adjtime file and records in it the current time as the last time the clock was calibrated. 5 days later, the clock has gained 10 seconds, so you issue another hwclock --set command to set it back 10 seconds. Hwclock updates the adjtime file to show the current time as the last time the clock was calibrated, and records 2 seconds per day as the systematic drift rate. 24 hours go by, and then you issue a hwclock --adjust command. Hwclock consults the adjtime file and sees that the clock gains 2 seconds per day when left alone and that it has been left alone for exactly one day. So it subtracts 2 seconds from the Hardware Clock. It then records the current time as the last time the clock was adjusted. Another 24 hours goes by and you issue another hwclock --adjust. Hwclock does the same thing: subtracts 2 seconds and updates the adjtime file with the current time as the last time the clock was adjusted. Every time you calibrate (set) the clock (using --set or --systohc), hwclock recalculates the systematic drift rate based on how long it has been since the last calibration, how long it has been since the last adjustment, what drift rate was assumed in any intervening adjustments, and the amount by which the clock is presently off. </quote> That seems pretty clear to me. Of course its totally irrelevant to me since I use the ntp daemon. I could probably get by if my hwclock battery ran out :-) Mind you /etc/cron.daily/suse.de-check-battery should tell me if my battery is running low or dead. <quote src="man page for hwclock"> Automatic Hardware Clock Synchronization By the Kernel You should be aware of another way that the Hardware Clock is kept synchronized in some systems. The Linux kernel has a mode wherein it copies the System Time to the Hardware Clock every 11 minutes. This is a good mode to use when you are using something sophisticated like ntp to keep your System Time synchronized. This mode (we'll call it "11 minute mode") is off until something turns it on. The ntp daemon xntpd is one thing that turns it on. You can turn it off by running anything, including hwclock --hctosys, that sets the System Time the old fashioned way. To see if it is on or off, use the command adjtimex --print and look at the value of "status". If the "64" bit of this number (expressed in binary) equal to 0, 11 minute mode is on. Otherwise, it is off. If your system runs with 11 minute mode on, don't use hwclock --adjust or hwclock --hctosys. You'll just make a mess. It is acceptable to use a ' hwclock --hctosys at startup time to get a reasonable System Time until your system is able to set the System Time from the external source and start 11 minute mode. </quote> Since I'm running ntp (and it doesn't matter if its daemon or "-q" from cron) the "11 minute mode" applies and I don't have to worry about syncing system to hardware "manually". Automatic is nice. But then there is one other thing that matters in all this. What are the settings in your /etc/fstab? Many people, especially those with laptops, mount files systems with noatime,nodiratime to reduce the disk activity. If you're not updating the access times than the clock doesn't matter, does it? So, the answer to your question "I would like the system automatically set/keep the time" is "Use NTP in daemon or '-q' mode" That also deals with the situation I have with my laptop where its turned on and of frequently. The "connected to the net occasionally only" is not going be a hurdle so long as there is connection often enough. You should establish how much clock drift you can tolerate. A server supplying a service to many people and having legal and contractual obligations will be more demanding than a netbook used for recording notes in a rain-forest or a desert, away from normal contact. But then that server will also have a reliable connection to fulfil those terms of service. One other factor is 'anacron'. (go google) It can be set up to ensure that cron jobs with a small periodicity are not missed on systems that are not up continuously. This is an excellent way to ensure that 'ntpd -q' is run. Try http://www.ibm.com/developerworks/linux/library/l-anacron/?ca=dgr-lnxw06Anacron&S_TACT=105AGX59&S_CMP=grlnxw06 That being said, the openSuse version of cron supports notation like @reboot : Run once, at startup. which isn't the same thing, but in this context will suffice to make sure 'ntpd -q' is run at startup. -- Almost all quality improvement comes via simplification of design,manufacturing, layout, processes, and procedures. -- Tom Peters -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Saturday, 2011-02-19 at 08:58 -0500, Anton Aylward wrote: ...
Of course its totally irrelevant to me since I use the ntp daemon. I could probably get by if my hwclock battery ran out :-)
Actually, no :-) First, because all disk writes before the ntp daemon succeeds on boot will be wrong by some years, and second, because all your bios settings would be reset to defaults: bios settings are stored into a battery backed RAM which originally was in the same hw clock chip (the cmos clock). And probably your bios start up sequence would stop with a warning, too.
Since I'm running ntp (and it doesn't matter if its daemon or "-q" from cron) the "11 minute mode" applies and I don't have to worry about syncing system to hardware "manually".
Automatic is nice.
If you have a permanent network connection and ntp running, yes :-)
But then there is one other thing that matters in all this. What are the settings in your /etc/fstab?
Many people, especially those with laptops, mount files systems with noatime,nodiratime to reduce the disk activity. If you're not updating the access times than the clock doesn't matter, does it?
It would, actually, but the error the adjtime corrects is typically rather small. Once the system boots the hwclock is not relevant. It is the system clock that is used. Even if the clock is wrong by several minutes on boot, it doesn't matter for the typical system. Only if the system thought that the clock had gone backwards, it would be a problem, it would fsck the disk.
One other factor is 'anacron'. (go google) It can be set up to ensure that cron jobs with a small periodicity are not missed on systems that are not up continuously. This is an excellent way to ensure that 'ntpd -q' is run.
You can set it to run when network goes up. IIRC, the ip-up script had it. - -- Cheers, Carlos E. R. (from 11.2 x86_64 "Emerald" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (GNU/Linux) iEYEARECAAYFAk1gO1UACgkQtTMYHG2NR9VzVgCfXDU3cKOC0oJuZsEZ3iYueErW XLUAn36SukYcx4lC42iRjS5Mw5csHQp7 =l7OF -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Carlos E. R. wrote:
Since I'm running ntp (and it doesn't matter if its daemon or "-q" from cron) the "11 minute mode" applies and I don't have to worry about syncing system to hardware "manually".
Automatic is nice.
If you have a permanent network connection and ntp running, yes :-)
I have had a permanent connection for 7-8 years by now, so I don't really remember, but afair ntpd can default to the local clock when there is no external signal. ntpd will know how much the local clock drifts, and can compensate for that such that time accuracy is actually quite good even during periods without a connection. -- Per Jessen, Zürich (4.0°C) -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sunday, 2011-02-20 at 09:19 +0100, Per Jessen wrote:
I have had a permanent connection for 7-8 years by now, so I don't really remember, but afair ntpd can default to the local clock when there is no external signal. ntpd will know how much the local clock drifts, and can compensate for that such that time accuracy is actually quite good even during periods without a connection.
Yes, but this behaviour occurs after the clock has been "disciplined", and this can take days, perhaps weeks to happen. If the connection to internet is very sporadic it may not happen. In those cases it is better a different strategy - if you need an accurate clock. - -- Cheers, Carlos E. R. (from 11.2 x86_64 "Emerald" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (GNU/Linux) iEYEARECAAYFAk1hEesACgkQtTMYHG2NR9WtFwCfSwAMrg38n9XuNesITJo2B0JN uB4AnRRH2BKJh2SPCwh1gJGP43eUq+bB =5gnb -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
2011. február 19. 14:58 napon Anton Aylward <anton.aylward@rogers.com> írta:
Istvan Gabor said the following on 02/19/2011 07:12 AM:
Hello:
My system clock tends to stray (1-2 minutes within a week, or so) So far I adjusted the time manually using the command: # sntp -r ntp1.ptb.de then setting hwclock # hwclcok --systohc
I would like the system automatically set/keep the time. I also discovered that there is no /etc/adjtime on my system. Is that normal?
Where could I find a decent description on how to use 1) adjtime method for keeping time, or 2) sntp in case when the system is turned off and on frequently and is connected to the net occasionally only.
The obvious answer to "where" is "have you googled?"
But a more practical answer starts with "how have you set up date and time with YAST?" I see a setting for turning NTP on and configuring it.
Start with yast -> system -> date and time
[long snip] Anton, Thank you very much the detailed answer. I will go through the man pages; I should have done it before. I checked sntp man page insetad of hwclock's. Thanks again. Istvan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
* Istvan Gabor <suseuser04@lajt.hu> [02-21-11 06:23]:
[long snip]
[shorter snip]
I will go through the man pages; I should have done it before. I checked sntp man page insetad of hwclock's.
You really mean ntp docs rather than hwclock's. hwclock maintains a reference but ntp keeps that reference adjusted. And actually that is incorrect, the software clock keeps the reference and ntp keeps that adjusted and hwclock maintains the time when the computer is not running. -- (paka)Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 http://en.opensuse.org openSUSE Community Member Registered Linux User #207535 @ http://counter.li.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Patrick Shanahan said the following on 02/21/2011 08:31 AM:
the software clock keeps the reference and ntp keeps that adjusted and hwclock maintains the time when the computer is not running.
Excellent precis! -- Any philosophy that can be put in a nutshell belongs there. -- Sydney J. Harris -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday, 2011-02-21 at 08:31 -0500, Patrick Shanahan wrote:
You really mean ntp docs rather than hwclock's. hwclock maintains a reference but ntp keeps that reference adjusted. And actually that is incorrect, the software clock keeps the reference and ntp keeps that adjusted and hwclock maintains the time when the computer is not running.
I'll write up another view of things :-) There are basically two clocks in a PC. One is mantained by the operating system, somehow (the "somehow" has varied during these years). It can run only while the system runs, obviously. There is another clock, in a cmos chip, that runs from a battery or from the main power, if available - so that it keeps the time while the computer is off. When the PC boots, "something" copies the cmos clock time to the system clock. That "something" can be the program hwclock. On boot it sets the system clock, and on halt it updates the cmos clock - rather, there is a suse script that does that, using hwclock. Then there are adjustements. The cmos clock drifts a constant value, that can be measured; as all quartz clocks, they are very stable, meaning they have an almost constant error. As it is a clock in a computer, the drift can be compensated: this is what the file /etc/adjtime is for. The calculated drift is added to the value read from the cmos clock, so that a corrected time is applied to the system clock. The system clock is different: its speed can be adjusted. The ntp daemon does that: it obtains a very accurate time from internet, then also adjusts the system clock making it go faster or slower till it runs as exact as it can be. But this requires a permanent internet connection (or a local GPS or other very reliable time source). So, another method of adjusting the system clock exists, by more or less manually adjusting its speed - if I recall correctly, by comparing to the cmos clock which has been previously corrected. This last method is what Istvan asked about, I think. - -- Cheers, Carlos E. R. (from 11.2 x86_64 "Emerald" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (GNU/Linux) iEYEARECAAYFAk1jDOMACgkQtTMYHG2NR9XImwCeI66Pw0xXWbladDhW4/Th2+Hp zNQAniAbuWS9MZmMLvqPRvVaKFkG/j0h =4/TG -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Saturday, 2011-02-19 at 13:12 +0100, Istvan Gabor wrote:
Hello:
My system clock tends to stray (1-2 minutes within a week, or so) So far I adjusted the time manually using the command: # sntp -r ntp1.ptb.de then setting hwclock # hwclcok --systohc
I would like the system automatically set/keep the time. I also discovered that there is no /etc/adjtime on my system. Is that normal?
No, it is not. Maybe you have to specify --utc or --localtime.
Where could I find a decent description on how to use 1) adjtime method for keeping time, or
man adjtimex, perhaps. Years ago someone commented on this in the list, IIRC. Perhaps here: <http://lists.opensuse.org/opensuse/2004-09/msg03845.html> - -- Cheers, Carlos E. R. (from 11.2 x86_64 "Emerald" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (GNU/Linux) iEYEARECAAYFAk1gNqYACgkQtTMYHG2NR9UiVwCePfsFZ/ndv9bdskiDPYWcTtpP /74AoIzEZMhRryqdQ+tVNx0nBH6lWAg5 =SJ68 -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (5)
-
Anton Aylward
-
Carlos E. R.
-
Istvan Gabor
-
Patrick Shanahan
-
Per Jessen