I found it mildly annoying that my BB would not set its clock for some
time after booting so I investigated. The BB does not use ntpd but
instead uses the sntp or simple network time protocol. This protocol
polls a time server, pool.ntp.org if nothing local is available, and
sets the clock.
A bit of poking around found that it is ntpdate is run out of cron every
30 minutes. So the time can be off for as long as 30 minutes. Unsat.
What I did was make ntpdate run at boot time. The normal run state is
one so I went into /etc/rc1.d and listed the directory. I wanted it to
run as the last task during booting. files are executed in rc1.d in
alphabetical order so they're numbered. The last file in my rc1.d is
K81portmap. So I did the following:
# cd /etc/rc1.d
# cat >K82ntp
/usr/bin/ntpdate -b -s -u pool.ntp.org &
The & puts runs the program in the background. It takes about 10
seconds to run so I didn't want to slow the boot time another 10
seconds. On my system, by the time the system is booted enough for me
to log in using ssh, the time is set.
Note that this works only if you're using the ethernet port to connect
with and if your LAN is gatewayed to the internet.
If you have a Linux machine that it always up, you can poll it instead
of the pool, taking some load off the pool. To do that change the above
/usr/bin/ntpdate -b -s -u your.local.server &
In my case, it's a Linux box named neonjohn so
/usr/bin/ntpdate -b -s -u neonjohn &
Hope this helps some of y'all
ntpdate has been deprecated in more recent Linux distros, it would probably make more sense to just use ntpd for this. The NTP protocol is very complex and takes into consideration things like network propagation delay between the client and clock source, the type of clock source used on the remote end to determine a time reference "clock stratums" I think they call it (atomic clocks references, 1PPS GPS clock references, etc). You won't get that level of sophistication with ntpdate, nor is it available in more recent generation Linux distributions.
Sorry that should have said "atomic clock reference"
I think the 1PPS GPS clock reference would be considered stratum 1, but you probably know that anyway if you have a DOE Q clearance
Surprisingly enough, I know all about stratums and how NTP works. But
NTP isn't on the BB as it is shipped. ntpupdate is. I doubt that very
many people who buy a BB are interested in switchings OSs just to get
NTP. So I wrote my tech tip using what is instead of what theoretically
Sorry to resurrect an old thread, but this is on the topic of setting time with NTP. I set the NTP server in /etc/default/ntpdate and ntpdate-sync works when run from the command line. I noticed in the crontab how it syncs the time on the :30 of every hour. I figured that changing the crontab entry to “@reboot /usr/bin/ntpdate-sync silent” would just have it do it once on startup, but that doesn’t work.
John, I’m going to use your method to set the time with an entry in rc1.d. But it has left me curious why @reboot doesn’t work and thought you might know the answer. I’m working on writing up a beginner’s guide to BeagleBone and I was hoping to keep it as simple as possible. I’m already covering cron, so I wish an @reboot entry in the crontab would work.
Have a look at http://derekmolloy.ie/automatically-setting-the-beaglebone-black-time-using-ntp/
systemctl and ntpdate running from the startup both might be the culprit as explained by Derek Molloy.