I'm currently wondering where Raspbian gets the "current" date and time during the boot on a RaspbianPI.

The system has a RTC device connected via I2C. The date/time from the RTC is read during boot by a systemd service unit which results in the correct date/time.

Additionally the NTP client is configured.

The fake-hwclock package is installed but deactivated in systemd.

While Raspbian is booting it generates log messages to /var/log/syslog with a date/time Nov 3 .... I expected it - as written by roaima - to be Jan 1 1970 but it is not ...

Example message in /var/log/syslog

Nov  3 18:16:51 raspberrypi kernel: [    0.000000] Booting Linux on physical CPU 0xf00

When systemd reaches the point where it runs my RTC script (the RTC device is connected via I2C) it sets the date and time correctly:

Oct 19 13:45:50 raspberrypi systemd[1]: Time has been changed

So, the question is: where is that strange Nov 3 date stored?! Is it somewhere stored in a file? Is it hardcoded into the kernel?


Raspberry Pi machines don't have a battery-backed RTC, so when they are powered up the clock starts from zero (midnight, January 1st 1970 UTC).

To get an approximation to true time at boot, before any external time source has been accessed, the fake-hwclock package provides a means to set the clock to a value saved at shutdown. On machines connected to the Internet, NTP can set the clock much more accurately quite quickly after the device has booted.

| improve this answer | |
  • Well, as I've written the RaspberryPi that I use is enhanced by an RTC connected via I2C. Upon the systemd-triggered read from the RTC, the date and time are correct. fake-hwclock is disabled in systemd. Before that moment, the November 3 ... date is shown in the syslog. So this date/time must come from somewhere? – Max Senft Oct 19 '17 at 13:59
  • @MaxSenft I thought we were talking about the boot times recorded before your RTC was read. – roaima Oct 19 '17 at 15:17
  • That's true, we're talking about the moments before the RTC has been read and/or NTP is active. The fake-hwclock package is installed but not activated in systemd. The /etc/fake-hwclock.data file contains a different date/time. So the source for the Nov 3 18:16:... date/time must be something else. – Max Senft Oct 19 '17 at 15:31
  • I updated the question earlier. I just did another test: I created a clean Raspbian Stretch Lite SD card and booted. fake-hwclock is activated of course. The date/time get's set to the date Wed 16 Aug 01:22:11 UTC 2017 by fake-hwclock. As soon as I disable fake-hwclock by update-rc.d fake-hwclock disbale and restart, the boot date/time is again this strange Thu 3 Nov 17:16:51 UTC 2016... – Max Senft Oct 20 '17 at 15:29

I had the same experience where my RPi with RTC and running NTP after upgrading to Stretch sometimes doesn't use the correct date/time.

Unfortunately I can't tell you where this 3 Nov 2016 17:16:45 in Stretch comes from, but I now I think I know under which circumstances this happens.

If I compare the good and "bad date/time after reboot" situations it seems that this 3 Nov 2016 17:16:45 is not corrected to the correct time (either from the RTC or NTP) when a WLAN connection is available, the RPi is connected but for some reason cannot access the internet.

As I am very new to this Linux stuff I don't know how I can prove this. And I am aware that I am not answering the question, but I felt this might be useful.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.