Raspberry Pi 4 Does not remember shutdown time
![](https://seccdn.libravatar.org/avatar/29495d4971cc39e3e98fb5119b7f1698.jpg?s=120&d=mm&r=g)
Hi, I'm running the RPI4 Tumbleweed JeOS image (https://en.opensuse.org/HCL:Raspberry_Pi4) on a RPI CM4. Unlike Raspberry Pi OS, it does not remember the shutdown time, it always shows May 16 on boot until chrony has set the correct time. Log from booting now: May 16 10:01:20 localhost kernel: Booting Linux on physical CPU 0x0000000000 [0x410fd083] May 16 10:01:20 localhost kernel: Linux version 6.9.1-1-default (geeko@buildhost) (gcc (SUSE Linux) 13.2.1 20240509 [revision b7a2697733d19a093cbdd0e200ffce069a4bc812], GNU ld (GNU Binutils; openSUSE Tumbleweed) 2.42.0.20240130-3) #1 SMP PREEMPT_DYNAMIC Fri May 17 11:59 ni211:~ # uptime 11:37:41 up 19 days 1:36, 1 user, load average: 0.97, 0.47, 0.18 Any solution to this? Jonas
![](https://seccdn.libravatar.org/avatar/abfe90da345b80b5d42295a6dc3b16ac.jpg?s=120&d=mm&r=g)
Why? Arguably Ras Pi OS has slightly more finesse. but neither OS is capable of giving the correct time until there is a connection to a time server as there is no persisting real time clock. Essentially, you want a wrong answer but different to the one you are getting. or am I missing something? C On Tuesday, 4 June 2024 12:44:03 BST Jonas Kvinge wrote:
Hi,
I'm running the RPI4 Tumbleweed JeOS image (https://en.opensuse.org/HCL:Raspberry_Pi4) on a RPI CM4.
Unlike Raspberry Pi OS, it does not remember the shutdown time, it always shows May 16 on boot until chrony has set the correct time.
Log from booting now:
May 16 10:01:20 localhost kernel: Booting Linux on physical CPU 0x0000000000 [0x410fd083] May 16 10:01:20 localhost kernel: Linux version 6.9.1-1-default (geeko@buildhost) (gcc (SUSE Linux) 13.2.1 20240509 [revision b7a2697733d19a093cbdd0e200ffce069a4bc812], GNU ld (GNU Binutils; openSUSE Tumbleweed) 2.42.0.20240130-3) #1 SMP PREEMPT_DYNAMIC Fri May 17 11:59
ni211:~ # uptime 11:37:41 up 19 days 1:36, 1 user, load average: 0.97, 0.47, 0.18
Any solution to this?
Jonas
![](https://seccdn.libravatar.org/avatar/9e1442c8a7cdf4313410bb27241e51cc.jpg?s=120&d=mm&r=g)
On Tue, 2024-06-04 at 12:54 +0100, outbox@difrenchal.scot wrote:
Why? Arguably Ras Pi OS has slightly more finesse. but neither OS is capable of giving the correct time until there is a connection to a time server as there is no persisting real time clock. Essentially, you want a wrong answer but different to the one you are getting. or am I missing something?
If possible, I would like it to remember the time it was shutdown, so uptime does not show many days wrong if I just do a reboot. Any idea how Raspberry Pi Os is doing it, or where to look? Jonas
![](https://seccdn.libravatar.org/avatar/c0cfd5b7246be604feb77f43a3c9626f.jpg?s=120&d=mm&r=g)
Am Dienstag, 4. Juni 2024, 13:59:49 MESZ schrieb Jonas Kvinge:
On Tue, 2024-06-04 at 12:54 +0100, outbox@difrenchal.scot wrote:
Why? Arguably Ras Pi OS has slightly more finesse. but neither OS is capable of giving the correct time until there is a connection to a time server as there is no persisting real time clock. Essentially, you want a wrong answer but different to the one you are getting. or am I missing something?
If possible, I would like it to remember the time it was shutdown, so uptime does not show many days wrong if I just do a reboot. Any idea how Raspberry Pi Os is doing it, or where to look?
you may want to try the package fake-hwclock (available on OBS using opi) which writes date and time periodically and uses this during the next boot HTH Axel
![](https://seccdn.libravatar.org/avatar/29495d4971cc39e3e98fb5119b7f1698.jpg?s=120&d=mm&r=g)
On Tue, 2024-06-04 at 17:25 +0200, Axel Braun wrote:
you may want to try the package fake-hwclock (available on OBS using opi) which writes date and time periodically and uses this during the next boot
HTH Axel
Thanks, it works. I checked, and see now that's what Debian uses too. The kernel boot logline still shows the old time unlike Debian, but uptime is adjusted when booted. So I still wonder what more Debian does since there the boot line is corrected too. Jonas
![](https://seccdn.libravatar.org/avatar/9435667f7160374bc34a8600b686aecd.jpg?s=120&d=mm&r=g)
On Thu, Jun 6, 2024 at 11:45 AM Jonas Kvinge
The kernel boot logline still shows the old time unlike Debian, but uptime is adjusted when booted. So I still wonder what more Debian does since there the boot line is corrected too.
The output format is obviously different so you are using different tools, different options or default options differ. Produce the output in identical format to compare.
![](https://seccdn.libravatar.org/avatar/29495d4971cc39e3e98fb5119b7f1698.jpg?s=120&d=mm&r=g)
On Thu, 2024-06-06 at 12:39 +0300, Andrei Borzenkov wrote:
On Thu, Jun 6, 2024 at 11:45 AM Jonas Kvinge
wrote: The kernel boot logline still shows the old time unlike Debian, but uptime is adjusted when booted. So I still wonder what more Debian does since there the boot line is corrected too.
The output format is obviously different so you are using different tools, different options or default options differ. Produce the output in identical format to compare.
Debian: Jun 04 14:41:50 WFD002000001.edge.vendanor.com kernel: Booting Linux on physical CPU 0x0000000000 [0x410fd083] Jun 04 14:41:50 WFD002000001.edge.vendanor.com kernel: Linux version 6.1.0-rpi6-rpi-v8 (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT Debian 1:6.1.58-1+rpt2 (2023-10-27) openSUSE: May 16 10:01:21 edge.vendanor.com kernel: Booting Linux on physical CPU 0x0000000000 [0x410fd083] May 16 10:01:21 edge.vendanor.com kernel: Linux version 6.9.1-1-default (geeko@buildhost) (gcc (SUSE Linux) 13.2.1 20240509 [revision b7a2697733d19a093cbdd0e200ffce069a4bc812], GNU ld (GNU Binutils; openSUSE Tumbleweed) 2.42.0.20240130-3) #1 SMP PREEMPT_DYNAMIC Fri May 17 11:59:46 UTC 2024 (0c0b0b5) Jonas
![](https://seccdn.libravatar.org/avatar/b90cf9b86b0da4d4a13a7b2aeac56292.jpg?s=120&d=mm&r=g)
W dniu 4.06.2024 o 13:44, Jonas Kvinge pisze:
Hi,
I'm running the RPI4 Tumbleweed JeOS image (https://en.opensuse.org/HCL:Raspberry_Pi4) on a RPI CM4.
Unlike Raspberry Pi OS, it does not remember the shutdown time, it always shows May 16 on boot until chrony has set the correct time.
Log from booting now:
May 16 10:01:20 localhost kernel: Booting Linux on physical CPU 0x0000000000 [0x410fd083] May 16 10:01:20 localhost kernel: Linux version 6.9.1-1-default (geeko@buildhost) (gcc (SUSE Linux) 13.2.1 20240509 [revision b7a2697733d19a093cbdd0e200ffce069a4bc812], GNU ld (GNU Binutils; openSUSE Tumbleweed) 2.42.0.20240130-3) #1 SMP PREEMPT_DYNAMIC Fri May 17 11:59
ni211:~ # uptime 11:37:41 up 19 days 1:36, 1 user, load average: 0.97, 0.47, 0.18
Any solution to this?
Jonas
RPi does not have on-board hardware clock with battery. But it can be added: https://pimylifeup.com/raspberry-pi-rtc/
![](https://seccdn.libravatar.org/avatar/29495d4971cc39e3e98fb5119b7f1698.jpg?s=120&d=mm&r=g)
On Tue, 2024-06-04 at 14:04 +0200, Adam Mizerski wrote:
RPi does not have on-board hardware clock with battery. But it can be added: https://pimylifeup.com/raspberry-pi-rtc/
I'm aware. I'm asking if the OS can remember the shutdown time and set that on boot before the time is synced with NTP, this way uptime will show more correctly when you reboot the system. Raspberry Pi Os does this somehow. Jonas
![](https://seccdn.libravatar.org/avatar/0ab1491ab50291fb6654bd364f499a4f.jpg?s=120&d=mm&r=g)
Op dinsdag 4 juni 2024 14:45:06 CEST schreef Jonas Kvinge:
On Tue, 2024-06-04 at 14:04 +0200, Adam Mizerski wrote:
RPi does not have on-board hardware clock with battery. But it can be added: https://pimylifeup.com/raspberry-pi-rtc/
I'm aware. I'm asking if the OS can remember the shutdown time and set that on boot before the time is synced with NTP, this way uptime will show more correctly when you reboot the system. Raspberry Pi Os does this somehow.
Jonas
If you disable chronyd.service and enable systemd-timesyncd.service the system will soon have the time of the last shutdown and when the network is up it will synchronize with a time server. -- fr.gr. member openSUSE Freek de Kruijf
![](https://seccdn.libravatar.org/avatar/29495d4971cc39e3e98fb5119b7f1698.jpg?s=120&d=mm&r=g)
On Tue, 2024-06-04 at 15:01 +0200, Freek de Kruijf wrote:
If you disable chronyd.service and enable systemd-timesyncd.service the system will soon have the time of the last shutdown and when the network is up it will synchronize with a time server.
chronyd is running on the Raspberry Pi Os installations too, without timesync systemd service, and there it's not an issue. And I don't see how a systemd service can solve this since it will be started after the kernel starts booting, but I've tested switching to timesync on openSUSE like you said, it does not solve any issue with the time. Debian after reboot shows: kernel boot: 2024-06-04T14:41:54.222699+00:00 WFD002000001 kernel: [ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd083] 2024-06-04T14:41:54.232954+00:00 WFD002000001 kernel: [ 0.000000] Linux version 6.1.0-rpi6-rpi-v8 (debian-kernel@lists.debian.org) (gcc- 12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT Debian 1:6.1.58-1+rpt2 (2023-10-27) date: Tue Jun 4 14:44:10 UTC 2024 uptime: 14:44:32 up 1 min, 2 users, load average: 3.85, 1.25, 0.44 openSUSE after reboot shows (same hardware as Debian), still May 16. kernel boot: May 16 10:01:21 edge.vendanor.com kernel: Booting Linux on physical CPU 0x0000000000 [0x410fd083] May 16 10:01:21 edge.vendanor.com kernel: Linux version 6.9.1-1-default (geeko@buildhost) (gcc (SUSE Linux) 13.2.1 20240509 [revision b7a2697733d19a093cbdd0e200ffce069a4bc812], GNU ld (GNU Binutils; openSUSE Tumbleweed) 2.42.0.20240130-3) #1 SMP PREEMPT_DYNAMIC Fri May date: Tue Jun 4 02:54:53 PM UTC 2024 uptime: 14:54:55 up 19 days 4:53, 2 users, load average: 4,86, 1,16, 0,38 Jonas
![](https://seccdn.libravatar.org/avatar/150bb68600b6f4527c14c79e81e90f53.jpg?s=120&d=mm&r=g)
On Tue, 04 Jun 2024 17:19:26 +0200
Jonas Kvinge
chronyd is running on the Raspberry Pi Os installations too, without timesync systemd service, and there it's not an issue. And I don't see how a systemd service can solve this since it will be started after the kernel starts booting, but I've tested switching to timesync on openSUSE like you said, it does not solve any issue with the time.
If you want to understand how Raspberry Pi OS does something, would you not do better asking on a Raspberry Pi list or forum? IIUC correctly systemd is active in the initrd so could potentially do things before the system is active. For the avoidance of doubt, I know nothing about your particular issue or how to solve it.
![](https://seccdn.libravatar.org/avatar/9435667f7160374bc34a8600b686aecd.jpg?s=120&d=mm&r=g)
On 04.06.2024 18:19, Jonas Kvinge wrote:
On Tue, 2024-06-04 at 15:01 +0200, Freek de Kruijf wrote:
If you disable chronyd.service and enable systemd-timesyncd.service the system will soon have the time of the last shutdown and when the network is up it will synchronize with a time server.
chronyd is running on the Raspberry Pi Os installations too, without timesync systemd service, and there it's not an issue. And I don't see how a systemd service can solve this since it will be started after the kernel starts booting, but I've tested switching to timesync on openSUSE like you said, it does not solve any issue with the time.
Debian after reboot shows:
Then find out how Debian does it and then we can look whether the same method is also available in openSUSE.
kernel boot: 2024-06-04T14:41:54.222699+00:00 WFD002000001 kernel: [ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd083] 2024-06-04T14:41:54.232954+00:00 WFD002000001 kernel: [ 0.000000] Linux version 6.1.0-rpi6-rpi-v8 (debian-kernel@lists.debian.org) (gcc- 12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT Debian 1:6.1.58-1+rpt2 (2023-10-27)
date: Tue Jun 4 14:44:10 UTC 2024
uptime: 14:44:32 up 1 min, 2 users, load average: 3.85, 1.25, 0.44
openSUSE after reboot shows (same hardware as Debian), still May 16.
kernel boot: May 16 10:01:21 edge.vendanor.com kernel: Booting Linux on physical CPU 0x0000000000 [0x410fd083] May 16 10:01:21 edge.vendanor.com kernel: Linux version 6.9.1-1-default (geeko@buildhost) (gcc (SUSE Linux) 13.2.1 20240509 [revision b7a2697733d19a093cbdd0e200ffce069a4bc812], GNU ld (GNU Binutils; openSUSE Tumbleweed) 2.42.0.20240130-3) #1 SMP PREEMPT_DYNAMIC Fri May
date: Tue Jun 4 02:54:53 PM UTC 2024
uptime: 14:54:55 up 19 days 4:53, 2 users, load average: 4,86, 1,16, 0,38
Jonas
![](https://seccdn.libravatar.org/avatar/9435667f7160374bc34a8600b686aecd.jpg?s=120&d=mm&r=g)
On Tue, Jun 4, 2024 at 3:45 PM Jonas Kvinge
On Tue, 2024-06-04 at 14:04 +0200, Adam Mizerski wrote:
RPi does not have on-board hardware clock with battery. But it can be added: https://pimylifeup.com/raspberry-pi-rtc/
I'm aware. I'm asking if the OS can remember the shutdown time and set that on boot before the time is synced with NTP, this way uptime will show more correctly when you reboot the system. Raspberry Pi Os does this somehow.
"OS" is not an undividable entity. Anything can be done if someone programs it. The systemd-timesyncd by default saves actual timestamp and restores it when initialized if the current time is in the past. You will still have some window before systemd-timesyncd is launched when time will be wrong. https://www.freedesktop.org/software/systemd/man/latest/systemd-timesyncd.se... You can write your own implementation if you like (in principle, it is just "touch /some/file" periodically/on shutdown and "date -r /some/file" on boot. It will have the same window before /some/file is accessible (so time in initrd will be off ... well, /some/file could be on ESP if you are using UEFI).
participants (8)
-
Adam Mizerski
-
Andrei Borzenkov
-
Axel Braun
-
Dave Howorth
-
Freek de Kruijf
-
Jonas Kvinge
-
Jonas Kvinge
-
outbox@difrenchal.scot