Get the App
SLTechnology News&Howtos  ›  Development  › 

How to set hardware time with Linux hwclock command

Shulou Source: shulou.com Published: 2022-06-01 18:51:29 10月03日 Update

This article introduces the knowledge about "how to set hardware time with Linux hwclock command". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

Linux common command hwclock command is a hardware clock access tool, it can display the current time, set the hardware clock time and set the hardware clock to the system time, can also set the system time to the hardware clock time.

hwclock display and set hardware clock

The hwclock command is a hardware clock access tool that can display the current time, set the hardware clock time, and set the hardware clock to system time, as well as set the system time to hardware clock time.

There are two types of clock in Linux: hardware clock and system clock. Hardware clock refers to the clock device on the motherboard, that is, the clock that can usually be set in the BIOS screen. The system clock is the clock in the kernel. When Linux starts, the system clock reads the hardware clock settings, and then the system clock runs independently. All Linux-related commands and functions read the settings of the system clock.

Syntax hwclock(option) option--adjust: hwclock Every time the hardware clock is changed, it is recorded in the/etc/adjtime file. Use the--adjust parameter to enable hwclock to estimate the hardware clock bias based on previous records and use it to correct the current hardware clock; --debug: displays detailed information about hwclock execution; --directisa: hwclock defaults to accessing hardware clocks from/dev/rtc devices. If access is not possible, this parameter can be used to access the hardware clock directly with I/O instructions; --hctosys: adjust the system clock to match the current hardware clock; --set --date=: set the hardware clock; --show: display the time and date of the hardware clock; --systohc: adjust the hardware clock to match the current system clock; --test: test the program only, without actually changing the hardware clock; --utc: To use Greenwich Time, add this parameter, hwclock performs the conversion; --version: Displays version information. Example setting hardware time depends on operating system time, as follows:

hwclock-systohc hwclock --systohc--utc without any parameters Use hwclock to view the current hardware date and time.

hwclock Check the clock file to make sure UTC is set:

cat /etc/default/rcS UTC=yes In some other versions of Linux, such as RebHat, you can see this:

cat /etc/sysconfig/clock ZONE="America/Los_Angeles" UTC=false ARC=false"How to set hardware time with Linux hwclock command" is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Tags: Clock hardware time system command parameter access consistency information content actual tool instruction file date more version knowledge device can be set Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Redmi Shulou Tech Info NVidia macOS