Wrong date when starts, reboot or lost internet connection


I have problems with the date in the Yun, sometimes it's wrong. The Yun send data to a server and is very inportant the date sent is correct. The problem comes when the yun reboots and when the internet connection is lost and when the socket reconnects the date sometimes is wrong.

I added to the Lucy console in the System --> Startup --> Local Startup the next code:


ntpd -q -p 0.openwrt.pool.ntp.org


exit 0

But still the date is wrong sometimes.

Some workaround to fix this problem?


The Yun has no real time clock. When it starts up, it makes an NTP request over the Internet to get the proper date and time. That can't happen if there is no internet connection, so it makes its best guess - which is certainly bound to be wrong. You've added an extra call to make another NTP request during startup, but that still requires an Internet connection, so it will also fail. As you discovered, your added NTP call accomplishes nothing - if you have an Internet connection, it's redundant; if you have no connection it still doesn't work.

If it's critical that you always have the correct date and time when you start up, then you will need to add some sort the f real time clock: either a battery backed up chip, a GPS receiver, cellular kink, or something similar.

Thanks for your answer.

There are some way to programatically make a NTP request when the internet connection is recovered