Raspbian NTP Auto-Update

I figured out the issue of our Raspbian kiosks not keeping time. It has to do with the Pi lacking any RTC, etc. So the first step was to change /etc/ntp.conf, to comment out the lines referencing the official debian servers and add a few of our DCs. This was necessary because these kiosks can’t connect to anything outside their VLAN.

yes, .local - don't judge me.
yes, .local – don’t judge me.

You can test it by entering LXTerminal and running “/etc/init.d/ntp restart”. Give it a minute and your time should update. Then, to automate it, you want to use crontab. In the terminal, write ‘crontab -e’ to edit your current user’s cron table. Then, my choice was to run the NTP restart command once an hour, so it looks like “01 * * * * /etc/init.d/ntp restart”, meaning at minute 01, every hour, every day of the month, every month, every day of the week, it will restart the NTP daemon.

crontab hourly NTP update
crontab hourly NTP update

If your setup is anything like mine, you’ll need to rewrite the crontab for the user actually running whatever you’ve got going on your kiosk (for us, Chromium run as user ‘pi’). When I TightVNC into the pi, it’s automatically as root, so the user can continue to use the kiosk and doesn’t see what I’m doing. To do that, in the terminal write “crontab -u pi -e”, followed by the same command as written above.

Now all I need to do is connect to all 15 kiosks and modify the crontabs. Fun.

Featured image: Martin’s Atelier

Leave a Reply

Your email address will not be published. Required fields are marked *