TrumanWong

clock

Used to adjust RTC time

Supplementary instructions

clock command is used to adjust the RTC time. RTC is the computer's built-in hardware time. Executing this command can display the current time, adjust the time of the hardware clock, set the system time to be consistent with the time of the hardware clock, or save the system time back to the hardware clock.

grammar

clock [--adjust][--debug][--directisa][--getepoch][--hctosys][--set --date="<datetime>"]
[--setepoch --epoch=< >][--show][--systohc][--test][--utc][--version]

Options

--adjust The first time you use the "--set" or "--systohc" parameter to set the hardware clock, a file named adjtime will be generated in the /etc directory. When these two parameters are used to adjust the hardware clock again, this file will record the difference between the two adjustments. When the clock command is executed with the "--adjust" parameter in the future, the program will automatically calculate the average based on the numerical difference in the recorded file. value to automatically adjust the time of the hardware clock.
--debug: Display the instruction execution process in detail, which is convenient for troubleshooting or understanding the program execution situation.
--directisa tells the clock command not to access the hardware clock directly through the /dev/rtc device file. This parameter is suitable for old computers with only ISA bus structure.
--getepoch Presents the new epoch value of the hardware clock in the system core to the standard output device.
--hctosys Hardware Clock to System Time, set the system time to be consistent with the hardware clock. Since this action will cause the system to fully update the file access time, it is best to execute it when the system starts.
--set--date Set the date and time of the hardware clock.
--setepoch--epoch=<year> Set the new era value of the system core's hardware clock. The year is represented by a four-digit tree character.
--show Read the time from the hardware clock and present it to the standard output device.
--systohc  System Time to Hardware Clock, save the system time back to the hardware clock.
--test is only for testing and does not actually write the time to the hardware clock or system time.
--utc Set the time on the hardware clock to CUT, sometimes also called UTC or UCT.
--version Display version information.

Example

Get the current time

clock # Get the current time

Show UTC time

clock -utc #Display UTC time