Posts: 1
Joined: Sat Oct 19, 2019 8:32 am

Time resets at boot

Sat Oct 19, 2019 8:42 am

I am running two raspberries (installed from NOOB) as dataloggers in a proof of concept, and I rely on timing for timestamping data-entries, and of course for running cronjobs. The berries are running without any internet connection.

Now - recently I noticed one of them had set the system time 3 months back - and moreover I discovered that it resat the time on every boot.
By playing round a little, I found that if I did timedatectl set-ntp false - it would NOT reset the time, but rather keep ticking.

What is the recommended (surefire) way of ensuring correct system time ?


Posts: 2650
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Time resets at boot

Sat Oct 19, 2019 1:02 pm

The Raspberry Pi doesn't have a Real Time Clock, like a PC does. Thus, it will lose time when shut down. With no Internet connection it has no way to sync its time with a Time server. Normally it will remember the time when it was shut down. And then update that with the correct time retrieved from the internet time service when it gets an internet connection..
You can add a RTC, I've done it on several of my Pi's. Two of which run headless with no Internet connection. Once I set it correctly its maintained even when I shut down. The RTC has a battery backup like the ones in a PC do.

User avatar
Posts: 39885
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Time resets at boot

Sat Oct 19, 2019 1:30 pm

fake-hwclock is supposed to store the time every 17 minutes past the hour. When the system restarts fake-hwclock loads the last stored time until your RPi can sync with the internets.

If it can't sync, you should consider adding a battery powered RTC.

If fake-hwclock can't write its status file you either a) have a read-only filesystem or b) have a knackered SDCard. Most likely reason is b).

For a read-only filesystem with no access to the internets you MUST have a RTC.

Test it, take a look at /etc/
Run sudo fake-hwclock save
Take another look.

Code: Select all

pi@intrepid:~$ cat /etc/
2019-10-19 13:17:00
pi@intrepid:~$ sudo fake-hwclock save
pi@intrepid:~$ cat /etc/
2019-10-19 13:29:47
Then reboot and take another look at it.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Return to “Troubleshooting”