3. RTC Test Commands in Linux¶
3.1. date and hwclock¶
date commandused to queryorsetcurrent Linux system (software) clock. Linux bootwhen, systemclockwillfromhardwareclock (RTC) synchronization.
hwclock commandused to queryorsethardwareclock (RTC) time.
Example:Set the system time
date "2020-10-17 9:48:30"
# Sat Oct 17 09:48:30 CST 2020
Example:Read the system time
date
# Sat Oct 17 09:48:34 CST 2020
Example:Read the hardware clock (RTC) time
hwclock
# Sat Oct 17 09:56:03 2020 0.000000 seconds
Example:Write the system time to the hardware clock
hwclock -w
Example:Synchronize the hardware clock to the system time
hwclock -s