Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
clock drift on each reboot
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
dgulotta
Tux's lil' helper
Tux's lil' helper


Joined: 09 Jan 2006
Posts: 88

PostPosted: Tue May 31, 2016 8:53 pm    Post subject: clock drift on each reboot Reply with quote

Every time I reboot, my system clock gets about 35 seconds farther behind. It seems that the problem is that the system time gets set at shutdown, but /etc/adjtime isn't updated to reflect the fact that the system time was adjusted. So at every boot the system thinks that it needs to compensate for all of the drift that happened since I last set the hardware clock manually. The problem seems to occur with sys-apps/util-linux-2.28 and 2.26.2, but it didn't occur with 2.25.2-r2. Is there any way I can fix this?

My /etc/conf.d/hwclock is just the standard one:
Code:
# Set CLOCK to "UTC" if your Hardware Clock is set to UTC (also known as
# Greenwich Mean Time).  If that clock is set to the local time, then
# set CLOCK to "local".  Note that if you dual boot with Windows, then
# you should set it to "local".
clock="UTC"

# If you want the hwclock script to set the system time (software clock)
# to match the current hardware clock during bootup, leave this
# commented out.
# However, you can set this to "NO" if you are running a modern kernel
# and using NTP to synchronize your system clock.
#clock_hctosys="YES"

# If you do not want to set the hardware clock to the current system
# time (software clock) during shutdown, set this to no.
#clock_systohc="YES"

# If you wish to pass any other arguments to hwclock during bootup,
# you may do so here. Alpha users may wish to use --arc or --srm here.
clock_args=""


Edit: I think this is a bug caused by hwclock --systohc changing its behavior in util-linux-2.26, and /etc/init.d/hwclock not being updated accordingly.
Back to top
View user's profile Send private message
venomfang
n00b
n00b


Joined: 22 Oct 2013
Posts: 2

PostPosted: Wed Jun 01, 2016 6:42 am    Post subject: Reply with quote

Here is where i would start:

1) Rule out this being a hardware problem (ex bad cmos/bios battery). This can be done by disabling the clock sync, doing a couple of reboot cycles and seeing if the time in the bios/uefi has drifted.

2) Are you using NTP at all to sync your time? If you are you should really set the clock_hctosys option to no. It is redundant if you have a reliable network connectin to an ntp server.

3) Do you get any errors when you hwclock --systohc? Does hwclock --show show the correct time after this? Just looking at ruling out the init script.

Hope this helps.
Back to top
View user's profile Send private message
chithanh
Developer
Developer


Joined: 05 Aug 2006
Posts: 2158
Location: Berlin, Germany

PostPosted: Wed Jun 01, 2016 12:05 pm    Post subject: Reply with quote

You can check this by running
Code:
# /etc/init.d/hwclock restart

If every time you do that the clock shifts by 35 seconds then this points to a bug in util-linux or the init scripts.
Back to top
View user's profile Send private message
cwr
Veteran
Veteran


Joined: 17 Dec 2005
Posts: 1969

PostPosted: Wed Jun 01, 2016 3:39 pm    Post subject: Reply with quote

For that reason, I don't adjust the CMOS clock at shutdown. I just let the clock run and either reset
it with calls to NTPD or (usually) adjust the relative system clock time with adjtime.

Will
Back to top
View user's profile Send private message
dgulotta
Tux's lil' helper
Tux's lil' helper


Joined: 09 Jan 2006
Posts: 88

PostPosted: Thu Jun 02, 2016 4:47 pm    Post subject: Reply with quote

The drift happens when I run /etc/init.d/hwclock restart. I added some echo statements and it seems that the script runs hwclock --hctosys (which takes drift into account) and hwclock --systohc --noadjfile (which updates the harwareclock without updating /etc/adjtime).
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum