Skip to content

Real Time Clock

Get current time (system and hardware)⚓︎

On modern distributions, timedatectl can be used to get detailed time and date information.

# timedatectl
               Local time: Fri 2023-12-15 13:22:09 UTC
           Universal time: Fri 2023-12-15 13:22:09 UTC
                 RTC time: Fri 2023-12-15 13:21:40
                Time zone: Universal (UTC, +0000)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no

The Linux system time is synchronized with the internal real time clock at boot time.

If timedatectl is missing, system and time can be read out using the date command.

# date
Fri Dec 15 13:32:31 UTC 2023

Hardware time:

# hwclock
2023-12-15 13:31:46.826215+00:00

Set system time⚓︎

timedatectl set-time "2023-12-15 13:10:00"


date --set="20231215 13:10"

On our default images we try to synchronize time from on an ifup networking event. If we succeed with the ntpdate command we synchronize the system time to hardware clock (main CPU internal real time clock).

See /etc/network/if-up.d/ntpdate-sync and /etc/default/ntpdate on target system.

Set hardware clock to system time⚓︎

hwclock -w

Set system time to hardware clock⚓︎

hwclock --systohc

Set alarm (wake on RTC)⚓︎

Device path⚓︎

The internal real time clock can be found at /dev/rtc0.