Linux clock Command
The Linux clock command is used to adjust the RTC time.
RTC is the hardware clock built into the computer. Running this command can display the current time, adjust the hardware clock, set the system time to match the hardware clock, or store the system time back into the hardware clock.
Syntax
clock [--adjust][--debug][--directisa][--getepoch][--hctosys][--set --date="<日期时间>"][--setepoch --epoch=< >][--show][--systohc][--test][--utc][--version]
Parameter Description:
- --adjust The first time you use the "--set" or "--systohc" option to set the hardware clock, a file named adjtime is created in the /etc directory. When you use these two options again to adjust the hardware clock, this file records the difference between the two adjustments. Later, when the clock command is run with the "--adjust" option, the program automatically calculates the average from the recorded values and adjusts the hardware clock accordingly.
- --debug Display the command execution process in detail, to help with troubleshooting or understanding how the program runs.
- --directisa Tell the clock command not to access the hardware clock through the /dev/rtc device file, but directly. This option is suitable for older computers with only an ISA bus architecture.
- --getepoch Display the new-epoch value of the hardware clock in the system kernel to standard output.
- --hctosys Hardware Clock to System Time: set the system time to match the hardware clock. Because this action causes the system to update the access times of all files, it is best to run it at system startup.
- --set--date Set the date and time of the hardware clock.
- --setepoch--epoch=
Set the new-epoch value of the hardware clock in the system kernel; the year is expressed as a four-digit number. - --show Read the time of the hardware clock and display it to standard output.
- --systohc System Time to Hardware Clock: store the system time back into the hardware clock.
- --test For testing only; do not actually write the time to the hardware clock or system time.
- --utc Treat the time on the hardware clock as CUT, sometimes also called UTC or UCT.
- --version Display version information.
Example
Get the current time
# clock //获取当前的时间
Display the UTC time
# clock -utc //显示UTC时间
Linux Command Reference