If you have network access, ntpd will start very shortly after boot in stock Raspbian and Raspbian Lite distributions. You don't have to do anything to configuration files or firewalls. ntpd will keep the time in sync automatically for as long as it can reach a network. The ‘poll’ column from ntpq -pn
tells you how often, in seconds, it resyncs with a time server. This from one of my Raspberry Pis that has been up for a while:
Code: Select all
$ ntpq -pn
remote refid st t when poll reach delay offset jitter
*184.108.40.206 220.127.116.11 2 u 126 1024 377 132.040 -2.357 4.541
-18.104.22.168 22.214.171.124 3 u 957 1024 377 38.439 -3.759 3.290
+2600:3c03::f03c 126.96.36.199 2 u 451 1024 375 42.436 5.293 5.000
+188.8.131.52 0.60.139.194 2 u 722 1024 377 270.749 0.544 3.068
The offset and jitter values should be non-zero. In the example you posted they were zero, indicating no connection.
So maybe there's something else that's the problem:
- Does your Zero talk to the network? A quick test would be ping -c 5 raspberrypi.org. If you get ‘64 bytes from …’ results, you're good. ‘… Destination Host Unreachable’ is not good.
- Have you set your timezone with sudo raspi-config, then 4 Localisation Options followed by I2 Change Timezone? Linux maintains its internal time in UTC, and manages its presentation of time to the user through the timezone system.
- Apart from setting the time, what are you trying to do with your Zero? There are many (almost far too many) ways to start a task at boot, and you might be going about it the hard way.
I wouldn't worry to much about obfuscating host names. Better to post output as plain text in Code blocks. Also, threads from Raspberry Pi Forums, Stackexchange, SuperUser, etc from before early 2016 will provide misleading information, as the startup process has changed significantly.
The suggested delay-after-startup could be as simple as something like this in cron (edited with crontab -e
Code: Select all
@reboot sleep 30; /path/to/the/script/you/want/to/run …
This is pretty crude, and assumes that the clock should be set by ntpd within 30 s of booting.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.