You are not logged in.

#1 2013-07-12 13:52:12

Vortex375
Member
Registered: 2009-02-24
Posts: 61

Unable to set hardware clock

Hi everyone,

I have chronyd running on my system to automatically set the system clock via ntp. However, when I don't have internet connection the system time is very wrong after every reboot.

Also, when I connect to the internet later on, the system clock is set backwards which causes random problems.

I tried to set the hardware clock to the correct time using hwclock, but it does not work:

# hwclock -w
hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --debug option to see the details of our search for an access method.

# hwclock --debug
hwclock from util-linux 2.23.1
hwclock: cannot open /dev/rtc: Device or resource busy
No usable clock interface found.
hwclock: Cannot access the Hardware Clock via any known method.

What can I do?

Offline

#2 2013-07-12 13:57:15

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,597

Re: Unable to set hardware clock

have you tried stopping chrony? Maybe it's tying things up.

Offline

#3 2013-07-12 14:03:42

SolarBoyMatt
Member
Registered: 2012-01-07
Posts: 263

Re: Unable to set hardware clock

Why not just start ntp as a daemon?

Offline

#4 2013-07-12 14:04:32

Vortex375
Member
Registered: 2009-02-24
Posts: 61

Re: Unable to set hardware clock

Worked (I had to stop chrony)! :-)

That was a lot easier than expected. Thank you very much!

By the way, shouldn't my hardware clock sync automatically on shutdown?

(I tried both chrony and openntpd - I found chrony to be more reliable. openntpd had to be restarted manually every time after losing the connection to the internet)

Last edited by Vortex375 (2013-07-12 14:06:43)

Offline

#5 2013-07-12 14:06:22

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: Unable to set hardware clock

Vortex375 wrote:

By the way, shouldn't my hardware clock sync automatically on shutdown?

No, it shouldn't.

edit, longer version: Your system clock (not your hardware clock) cannot be relied on, so it doesn't make sense to write that time back to the hardware clock. If you care about having accurate time, you'll be running an NTP daemon. If you're running an NTP daemon, your hardware clock is updated regularly, so sync'ing at shutdown would be redundant.

Last edited by falconindy (2013-07-12 14:07:42)

Offline

#6 2013-07-12 14:07:40

Vortex375
Member
Registered: 2009-02-24
Posts: 61

Re: Unable to set hardware clock

It seems chrony did not update my hardware clock though. Do I have to set an option for that?

Last edited by Vortex375 (2013-07-12 14:08:21)

Offline

#7 2013-07-12 14:08:09

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,597

Re: Unable to set hardware clock

I'm not sure if it does under systemd or not, but even under initscripts, it wouldn't if it was that far out of sync IIRC.

Offline

#8 2013-07-12 14:57:55

mcloaked
Member
From: Yorkshire, UK
Registered: 2012-02-02
Posts: 1,240

Re: Unable to set hardware clock

Vortex375 wrote:

Hi everyone,

I have chronyd running on my system to automatically set the system clock via ntp. However, when I don't have internet connection the system time is very wrong after every reboot.

Also, when I connect to the internet later on, the system clock is set backwards which causes random problems.

I tried to set the hardware clock to the correct time using hwclock, but it does not work:

# hwclock -w
hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --debug option to see the details of our search for an access method.

# hwclock --debug
hwclock from util-linux 2.23.1
hwclock: cannot open /dev/rtc: Device or resource busy
No usable clock interface found.
hwclock: Cannot access the Hardware Clock via any known method.

What can I do?

You can have the chrony daemon running and then from the command line use chronyc - if you do that without parameters, then you will get a prompt and can then enter commands into chronyc.

Certain more critical commands require you to enter the password that you created when you set up chrony.  So once you have the prompt then you can do the following:

# chronyc
chrony version 1.27
Copyright (C) 1997-2003, 2007, 2009-2012 Richard P. Curnow and others
chrony comes with ABSOLUTELY NO WARRANTY.  This is free software, and
you are welcome to redistribute it under certain conditions.  See the
GNU General Public License version 2 for details.

chronyc>
password mychronypass
200 OK
chronyc>

In a different terminal check the "system time" using for example "date" - if that is off then chrony is not synced properly - if the time sources are selected well for your location it usually only takes a couple of minutes to get the system time synced to within milliseconds.

What I do is to use the "tracking" command to see if chrony is synchronised, and if chrony is synced properly then you can use "trimrtc" to write to the hardware clock whilst chrony is running if the current time is a long way off the reference time.

Also checkout the "makestep command. The arch wiki has a good page on chrony setup also.

Hope this helps.

Last edited by mcloaked (2013-07-12 15:01:27)


Mike C

Offline

Board footer

Powered by FluxBB