techskies11
Posts: 73
Joined: Sat Apr 02, 2016 8:45 am

how does the pi keep track of time without a real tine clock

Sun Jun 30, 2019 10:32 pm

I understand that the pi doesn't have a real time clock, but it has the option to get the time from the Internet, but what if internet is not available, hoes does the files on my the device keep track, wouldn't it mess up file dates and etc, im not sure since computers I use have a real time clock, if I use the pi as a computer without it, im not sure what to expect without a real time clock.

Timescale
Posts: 79
Joined: Wed Jun 26, 2019 5:09 pm

Re: how does the pi keep track of time without a real tine clock

Sun Jun 30, 2019 10:39 pm

It doesn't. Probably reverts back to a default timestamp or the last logged on or something.

If your boards must remain offline and you need accurate time, then installing an RTC if your only real quick fix.

plugwash
Forum Moderator
Forum Moderator
Posts: 3524
Joined: Wed Dec 28, 2011 11:45 pm

Re: how does the pi keep track of time without a real tine clock

Sun Jun 30, 2019 11:05 pm

First some terminology, most computer have two clocks, the "system clock" is implemented in the OS based on the processor's internal timers, this clock has high precision but only ticks while the system is running. The "hardware clock" or "rtc" is a seperate low power clock with a battery used to keep time when the system is not running.

The pi, in common with many cheap SBCs has a system clock, but does not have a hardware clock. So time ticks normally while the kernel is running, but cannot be tracked while the system is turned off. A script called "fake-hwclock" saves the time to a file on shutdown and on a hourly cron timer, then reloads it on boot. This keeps the time moving in the right direction (which is important for several reasons) but it obviously means that the time on the pi will become more and more out of step with real time.

Return to “General discussion”