cancel

[Technical tips] Read and set onboard real time clock under Linux

December 27, 2023

In Linux systems, two essential clocks keeping the time: the hardware clock and the system clock (system tick).
The hardware clock retains time even when the system is powered off, while the system clock is managed by the operating system. At boot time, the system initializes by reading the hardware time to set the system clock. From then on, the system clock keeps track of time during system operation.


Reading the RTC:

You can read the system's RTC using the hwclock command.

# To read the RTC and display the current date and time.

sudo hwclock

rufus_fdos-2

Setting the RTC:

To set the RTC, you'll typically use the hwclock command with the --set flag followed by the new date and time.

# Set the RTC to a specific date and time (replace YYYY-MM-DD HH:MM:SS with the desired date and time)

sudo hwclock --set --date="YYYY-MM-DD HH:MM:SS"

rufus_fdos-2

Ensure you have the necessary permissions (often requiring sudo or running as root) to access and modify the RTC.

Remember, modifying the RTC can have system-wide implications, so use caution when setting the clock manually.

You might also want to sync the system clock with the RTC or vice versa.

Syncing System Clock with RTC:

# To sync the system clock with the RTC

sudo hwclock --hctosys



# To sync the RTC with the system clock

sudo hwclock --systohc

Maintaining proper time synchronization is essential for system integrity and accurate time tracking. Always exercise care when manipulating time settings, especially with critical systems.


VDX3-6755

Main features of VDX3-6755:

  • DM&P SoC Vortex86DX3- 1GHz
  • 1GB DDR3 onboard
  • 3S / 2U / VGA / LVDS / GLAN / LAN / CAN / SATA
  • Operating Temperature: -20 ~ +70°C / -40 ~ +85°C (Optional)
  • Isolated RS232 / 485
  • Single channel 24-bit LVDS
  • Optional: Isolated CANbus

For more info and sample request, please write to info@icop.com.tw, call your nearest ICOP Branch, or contact our Worldwide Official Distributor.

Δ