Linux clock command
The Linux clock command is used to adjust the RTC time.
RTC is the built-in hardware time of the computer. Executing this command can display the current time, adjust the hardware clock time, set the system time to be consistent with the hardware clock time, or save the system time back to the hardware clock.
Syntax
clock [--adjust][--debug][--directisa][--getepoch][--hctosys][--set --date="<日期时间>"][--setepoch --epoch=< >][--show][--systohc][--test][--utc][--version]
Parameter description:
- --adjust: When using the "--set" or "--systohc" parameter for the first time to set the hardware clock, a file named adjtime will be generated in the /etc directory. When these two parameters are used again to adjust the hardware clock, this file will record the difference between the two adjustments. Later, when the clock command is executed with the "--adjust" parameter, the program will automatically calculate the average based on the numerical difference in the record file and automatically adjust the time of the hardware clock.
- --debug: Displays the command execution process in detail, making it easy to troubleshoot or understand how the program is running.
- --directisa: Tells the clock command not to access the hardware clock through the /dev/rtc device file, but directly. This parameter is applicable to old computers with only ISA bus structure.
- --getepoch: Outputs the hardware clock's epoch value in the system kernel to the standard output device.
- --hctosys: Hardware Clock to System Time, sets the system time to be consistent with the hardware clock. Since this action will cause the system to comprehensively update file access times, it is best to execute it at system startup.
- --set--date: Sets the date and time of the hardware clock.
- --setepoch--epoch=<year>: Sets the epoch value of the hardware clock in the system kernel, with the year expressed as four digits.
- --show: Reads the time of the hardware clock and displays it to the standard output device.
- --systohc: System Time to Hardware Clock, saves the system time back to the hardware clock.
- --test: Only for testing, does not actually write the time to the hardware clock or system time.
- --utc: Treats the time on the hardware clock as CUT, sometimes also called UTC or UCT.
- --version: Displays version information.
Examples
Get the current time
# clock //获取当前的时间
Display UTC time
# clock -utc //显示UTC时间Other extensions
Linux Commands Reference