# Manually Setting the System Clock

**URL:** <https://forums.balena.io/t/manually-setting-the-system-clock/93319>\
**Category:** Product support\
**Tags:** time\
**Created:** [April 13, 2020, 3:45pm UTC](https://forums.balena.io/t/manually-setting-the-system-clock/93319 "2020-04-13T15:45:58Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![AdamLee](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/adamlee/32/2149_2.png) [@AdamLee](https://forums.balena.io/u/AdamLee)\
**Post date:** [April 17, 2020, 3:49pm UTC](https://forums.balena.io/t/manually-setting-the-system-clock/93319/16 "2020-04-17T15:49:13Z")

</div>

This did not seem to work. I must admit it took a little bit to get it to function because I fell into this pitfall:

> [@Dbus: Failed to connect to socket /host/run/dbus/system](https://forums.balena.io/t/dbus-failed-to-connect-to-socket-host-run-dbus-system/3107/9):
>
> You are using the dbus-send command inside the Dockerfile. Instead of invoking it during build time, you need to do that in runtime from your start.sh script.

This is the reply from the dbus-send command:

```
17.04.20 09:58:00 (+0000) api method return time=1587117480.786902 sender=:1.1 -> destination=:1.6250 serial=177495 reply_serial=2
17.04.20 09:58:00 (+0000) api object path "/org/freedesktop/systemd1/job/79940"

```

When I changed the system time on the device, disconnected from the network, and power cycled it came up with a completely incorrect time. I thought originally that I would have to change the rtcsync directive in chrony to rtcfile, which is why I had originally asked how to edit that configuration:

> The `hwclock` program is often set-up by default in the boot and shutdown scripts with many Linux installations. With the kernel RTC synchronisation ( `rtcsync` directive), the RTC will be set also every 11 minutes as long as the system clock is synchronised. **If you want to use `chronyd` 's RTC monitoring ( `rtcfile` directive), it’s important to disable `hwclock` in the shutdown procedure. If you don’t, it will over-write the RTC with a new value, unknown to `chronyd` . At the next reboot, `chronyd` started with the `-s` option will compensate this (wrong) time with its estimate of how far the RTC has drifted whilst the power was off, giving a meaningless initial system time.**
> 
> There is no need to remove `hwclock` from the boot process, as long as `chronyd` is started after it has run.
> 
> [chrony – Frequently Asked Questions](https://chrony.tuxfamily.org/faq.html#_i_want_to_use_code_chronyd_code_s_rtc_support_must_i_disable_code_hwclock_code)

After reconnecting to the network, and then power cycling again it’s clear that NTP was used because the system time now reflects the current UTC time.

---

_[View the full topic](https://forums.balena.io/t/manually-setting-the-system-clock/93319)._
