We're having a small issue with our Beagle Bone Blacks. Since they do not come with a RTC battery, when they lose power, the hardware clock gets messed up. I need a simple and clean way of syncing the hwclock to the system clock on boot. The system clock ofcourse gets its time from ntpd and so after it boots, the system clock is perfect. I'm right there at the solution, just need a few suggestions and a little bit of syntax.

I wanted and tried to add:

/sbin/hwclock --systohc

To /etc/init.d/ntp (inside and at the end of the start case) and at first this seemed to work, but now after a few more tests, its not working anymore., I'm not sure what changed. Maybe I just thought it worked.

I know hwclock -w works great and I know I could do something like put it in a cron job on boot, but I prefer to avoid cron if I can. Any other suggestions or syntax changes?


BTW, this is on Debian, but we need this to work on Ubuntu too.

  • What about putting that line inside of /etc/rc.local? Would that work? (just taking a shot in the dark here, chances are that it's wrong but if it is then I'll have learned something)
    – fouric
    Feb 27, 2015 at 20:49
  • 2
    Try stackoverflow.com/questions/28079968/… It seems like it should work
    – coteyr
    Feb 27, 2015 at 21:18

1 Answer 1


Install the fake-hwclock program:

# apt-get install fake-hwclock

fake-hwclock: Save/restore system clock on machines without working RTC hardware

 Some machines don't have a working realtime clock (RTC) unit, or no
 driver for the hardware that does exist. fake-hwclock is a simple set
 of scripts to save the kernel's current clock periodically (including
 at shutdown) and restore it at boot so that the system clock keeps at
 least close to realtime. This will stop some of the problems that may
 be caused by a system believing it has travelled in time back to
 1970, such as needing to perform filesystem checks at every boot.

 On top of this, use of NTP is still recommended to deal with the fake
 clock "drifting" while the hardware is halted or rebooting.

With fake-hwclock installed your machine will not start up thinking it is 1970 all over again. When your machine boots up it will set its clock to the timestamp fake-hwclock wrote during the last reboot/shutdown. This means you can have a somewhat correct clock in case there are network issues when you boot up.

  • Yeah I saw that package too. Thought I had found the perfect solution, but it doesn't seem to work.
    – Atomiklan
    Mar 2, 2015 at 15:39
  • You should file a bug report. It should work
    – dfc
    Mar 2, 2015 at 16:00
  • If you run the last command, it still thinks the unit booted 1970-01-01 - even with fake-hwclock installed :( - seems wtmp is updated before fake-hwclock starts. May 30, 2017 at 12:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .