wolfgang ziegler


„make stuff and blog about it“

Incorrect Date and Time on Raspberry Pi

May 29, 2017

I just took one of my (by now many) Raspberry Pis online and encountered a problem that has been bothering me again and again over time.

Date and time on this Raspberry Pi are way out of sync.

A quick Google search for that problem shows that this is a common problem for which many different solutions are proposed. None has worked for me so far.

The only reliable solution I came up with so far is using the sntp command followed by the -s <NTP_SERVER_NAME> switch.

$ sudo sntp -s at.pool.ntp.org
29 May 21:34:37 sntp[1127]: Started sntp
2017-05-29 21:34:37.801121 (-0100) -0.00042 +/- 0.012131 secs
2017-05-29 21:34:37.828776 (-0100) +0.003551 +/- 0.042328 secs
2017-05-29 21:34:37.846329 (-0100) -0.003973 +/- 0.022629 secs
2017-05-29 21:34:37.860680 (-0100) +0.00107 +/- 0.026764 secs

A quick check using the date proves that we have been successful.

$ date
Mon Mai 29 21:34:39 CEST 2017

To make sure that we still have the correct date and time after a reboot, I put the above command into the root's crontab to make sure it gets executed at boot time.

Open root's crontab.

$ sudo crontab -e

Add the command.

@reboot   /usr/bin/sntp -s at.pool.ntp.org

And that's all. Most importantly, I now have blogged about it so I can look it up the next time I run into this problem.

Tina Fey - Job well done animated gif from https://giphy.com