English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux clock command

Linux Command Manual

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="<date and time>"][--setepoch --epoch=< >][--show][--systohc][--test][--utc][--version]

Parameter Description:

  • --adjust for the first time--set parameter or--systohc parameter sets the hardware clock, and will/A file named adjtime is generated under 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, and later execute the clock command with the following--adjust"parameter, the program will automatically calculate the average value according to the recorded file value difference, and automatically adjust the time of the hardware clock.
  • --debug  Display detailed command execution process, convenient for troubleshooting or understanding the execution of the program.
  • --directisa  Tell the clock command not to go through/dev/rtc device file, directly access the hardware clock. This parameter is applicable to old computers with only ISA bus structure.
  • --getepoch  Present the new era 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 update the access time of files in full, 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 hardware clock of the system core, represented by four-digit numbers.
  • --show  Read the time of 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  Only for testing, does not really write the time to the hardware clock or system time.
  • --utc  Set the hardware clock time to CUT, sometimes also called UTC or UCT.
  • --version  Display version information.

Online Examples

Get the Current Time

# clock //Get the Current Time

Display UTC Time

# clock -utc //Display UTC Time

Linux Command Manual