Problems with Time management

Hi all,

its my first time using balena and im having a lot of troubles setting time in my devices. I 've read Time management docs without luck. For example, the doc say “Balena devices make use of the systemd-timesyncd service to keep the system time synchronized” but when i try “systemctl status systemd-timesyncd” i get “Unit systemd-timesyncd.service could not be found.”

Could you guys please help me? I need to setup the correct time for my apps.

Thank you!

Hey,

So, in balenaOS 2.29 at least, we are using Chrony to do NTP time sync. You can see details like so:

root@c562c95:~# systemctl status chronyd   
● chronyd.service - NTP client/server
   Loaded: loaded (/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/chronyd.service.d
           └─chronyd.conf
   Active: active (running) since Wed 2019-02-06 15:32:18 UTC; 1 weeks 5 days ago
     Docs: man:chronyd(8)
           man:chrony.conf(5)
 Main PID: 640 (chronyd)
   CGroup: /system.slice/chronyd.service
           └─640 /usr/sbin/chronyd -s -d

Feb 06 15:32:18 localhost systemd[1]: Started NTP client/server.
Feb 06 15:32:18 localhost chronyd[640]: 2019-02-06T15:32:18Z chronyd version 3.2 starting (+CMDMON +NTP +REFCLOCK +RTC -PRIVDROP -SCFILTER -SECHASH -SIGND +ASYNCDNS +IPV6 -DEBUG)
Feb 15 15:48:44 localhost chronyd[640]: 2019-02-15T15:48:44Z System time restored from driftfile
Feb 15 15:48:44 localhost chronyd[640]: 2019-02-15T15:48:44Z Frequency 3.897 +/- 0.836 ppm read from /var/lib/chrony/drift
Feb 15 15:48:59 c562c95 chronyd[640]: 2019-02-15T15:48:59Z Selected source 94.16.116.137
Feb 18 13:59:55 c562c95 chronyd[640]: 2019-02-15T15:48:59Z System clock wrong by 252655.250583 seconds, adjustment started
Feb 18 13:59:55 c562c95 chronyd[640]: 2019-02-18T13:59:55Z System clock was stepped by 252655.250583 seconds
Feb 18 13:59:56 c562c95 chronyd[640]: 2019-02-18T13:59:56Z Selected source 212.18.3.18
Feb 18 14:02:06 c562c95 chronyd[640]: 2019-02-18T14:02:06Z Selected source 188.39.213.7

Your application containers should have the correct time, as long as the host is sync’d correctly.

1 Like

Hi @richbayliss, thank you so much for your support. This is the status of my chrony daemon,

root@124aff8:~# systemctl status chronyd
Warning: The unit file, source configuration file or drop-ins of chronyd>
● chronyd.service - NTP client/server
Loaded: loaded (/lib/systemd/system/chronyd.service; enabled; vendor >
Drop-In: /etc/systemd/system/chronyd.service.d
└─chronyd.conf
Active: active (running) since Wed 2019-02-06 15:13:08 UTC; 1 weeks 6>
Docs: man:chronyd(8)
man:chrony.conf(5)

Its indeed working but could you please guide me how can i configure an specific timezone? My local time is 12:13:08 and my app is using the system time (15:13:08).

Thank you very much,
Cristián

I solved this using chronyc manual time but the configuration doesn’t persist after reboot.

Any advice would be greatly appreciated.

Thanks,
Cristián

Hi,

You can set the timezone in the container as described in the time management docs: https://www.balena.io/docs/reference/OS/time/

There is also an example linked there.

Regards!

1 Like