# Set-time-epoch result in invalid date when board boot without internet connection

**URL:** <https://hub.mender.io/t/set-time-epoch-result-in-invalid-date-when-board-boot-without-internet-connection/2729>\
**Category:** General Discussions\
**Created:** [October 23, 2020, 8:31am UTC](https://hub.mender.io/t/set-time-epoch-result-in-invalid-date-when-board-boot-without-internet-connection/2729 "2020-10-23T08:31:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [October 23, 2020, 8:31am UTC](https://hub.mender.io/t/set-time-epoch-result-in-invalid-date-when-board-boot-without-internet-connection/2729/1 "2020-10-23T08:31:25Z")

</div>

Hi,

I was hunting for an issue why when bumped to dunfell on orangepi zero date/time is set to 1.1.1970. It makes troubles for us as we on first run create some certificates (ok we can wait until date/time is valid) but also other files which are created have date 1.1.1970 which is bit awkward. I read in comment in meta-mender commit: 8d204ccc4ce2edfca3b9774b18319c3acbf83f95 that it help to not perform fsck on every boot but according systemd code when timestamp with build time is used then when date/time is synced timestamp is updated and we shouldn’t see an issue. Or am I missing something? Thanks.

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [October 23, 2020, 6:04pm UTC](https://hub.mender.io/t/set-time-epoch-result-in-invalid-date-when-board-boot-without-internet-connection/2729/2 "2020-10-23T18:04:37Z")

</div>

Hi @MarekBelisko as I recall the default in systemd is to use the timestamp of one of it’s source files as the default date when building. This caused problems where the system would automatically run an fsck since the date was close to correct but not actually correct. Changing the epoch value to 1/1/1970 eliminated the fsck as it just assumed that the file was intentionally created with that date. Or something like that anyway. I don’t know if this is still a problem but I think even poky does it this way now.

You may want to wait until time is synced before doing these steps. Even if you don’t start at 1/1/1970, the time/date stamps will be older than real time since the images are always created before you run them.

Drew

---

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [October 23, 2020, 6:56pm UTC](https://hub.mender.io/t/set-time-epoch-result-in-invalid-date-when-board-boot-without-internet-connection/2729/3 "2020-10-23T18:56:44Z")

</div>

I asked on systemd mailing list and Lennart propose to patch fsck 🙂 [https://lists.freedesktop.org/archives/systemd-devel/2020-October/045486.html](https://lists.freedesktop.org/archives/systemd-devel/2020-October/045486.html) I’m not against idea to set epoch time just it can confuse users that they will see somewhere in journalctl or systemctl logs with epoch date 😃 so maybe it should be documented somewhere so people are aware of that. Thanks

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [October 26, 2020, 8:34am UTC](https://hub.mender.io/t/set-time-epoch-result-in-invalid-date-when-board-boot-without-internet-connection/2729/4 "2020-10-26T08:34:36Z")

</div>

You can actually disable the `fsck` by setting the following:

```auto
# cat /etc/e2fsck.conf
[options]
        broken_system_clock = true

```

So imo we could remove [this](https://github.com/mendersoftware/meta-mender/blob/master/meta-mender-core/recipes-core/systemd/systemd_%25.bbappend) and leave it up to the user to set the `e2fsck.conf` appropriately if they do not have a working RTC.

On dunfell, reproducible builds where introduced and what ever `SOURCE_DATE_EPOCH` is set to, this will be the time epoch in all produced binaries that support this. This time will also be wrong (but maybe less wrong in your case?) and the only way to get a sane time at boot is to have a working RTC 🙂

---

<div class="post-metadata">

**Author:** ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)\
**Post date:** [October 27, 2020, 7:26am UTC](https://hub.mender.io/t/set-time-epoch-result-in-invalid-date-when-board-boot-without-internet-connection/2729/5 "2020-10-27T07:26:45Z")

</div>

AFAIK in reproducible builds SOURCE\_DATE\_EPOCH should be set to actual date/time then systemd takes care about setting more less correct date/time until ntp is started and adjust date/time to correct one. Should I create PR with removal of systemd\_%.bbappend and documenting how to set fsck? Thanks.

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [October 27, 2020, 9:01am UTC](https://hub.mender.io/t/set-time-epoch-result-in-invalid-date-when-board-boot-without-internet-connection/2729/6 "2020-10-27T09:01:46Z")

</div>

> about setting more less correct date/time

Yes, emphasis on more or less 🙂, but it still will not be correct as it be based on a timestamp generated during build.

Also note that systemd-timesync will create the following:

> `/var/lib/systemd/timesync/clock`

> > The modification time of this file indicates the timestamp of the last successful synchronization (or at least the systemd build date, in case synchronization was not possible).

Which it should use, if you have ever synced time before.

> [@MarekBelisko](#):
>
> Should I create PR with removal of systemd\_%.bbappend and documenting how to set fsck?

I vote in favor

---

<div class="post-metadata">

**Author:** ![nowls](https://avatars.discourse-cdn.com/v4/letter/n/919ad9/32.png) [@nowls](https://hub.mender.io/u/nowls)\
**Post date:** [August 19, 2024, 3:17pm UTC](https://hub.mender.io/t/set-time-epoch-result-in-invalid-date-when-board-boot-without-internet-connection/2729/7 "2024-08-19T15:17:44Z")

</div>

The [override](https://github.com/mendersoftware/meta-mender/blob/master/meta-mender-core/recipes-core/systemd/systemd_%25.bbappend) discussed in this thread is still in place on `master`, `scarthgap`, and `kirkstone`.

The override causes an error message from `systemd` on boot:

```auto
Aug 19 13:07:15 myhostname systemd[1]: Current system time is further ahead 15y after build time, but cannot correct: Invalid argument

```

@mirzak @TheYoctoJester can you please provide guidance on whether this override should be removed in favor of overriding `fsck` behavior? Thanks!
