Linux system time and hardware time settings

Source: Internet
Author: User

1. Introduction

There are two clocks of hardware clock and system clock in Linux. The hardware clock is the clock device on the motherboard, which is usually the clock that can be set on the BIOS screen. This time there is battery-powered maintenance on the motherboard, if the motherboard battery is exhausted, if the power outage, restore to the factory settings. The system clock refers to the clock in the kernel. All Linux-related instructions and functions are programmed to read the system clock. Because there are two different clocks, there is a difference between them. When Linux starts, the system clock reads the settings of the hardware clock, and then the system clock runs independently.
For system time, we can use the date command to view:

[Email protected]:~$ Date
Wed APR 15:52:23 CST 2015

Hardware time, using the Hwclock command to view

[Email protected]:~$ sudo hwclock–show//hardware time requires root privileges
[sudo] password for unicom:
Wed Apr 16:13:42 2015-0.844670 seconds

2. Time Settings

The time set with the date command does not modify the hardware time of the system, and the hardware time is still loaded after the system restarts, which is an issue that often causes the date setting time to expire.
The correct approach is to set the system time, then perform a time synchronization to the hardware clock, of course, the direct setting of the hardware clock is also possible.
Date sets the system clock.
 # date --set “04/15/15 16:19" (月/日/年 时:分:秒)
Synchronize the system time to the hardware clock:
 # sudo hwclock --systohcOr# sudo hwclock -w

To set the hardware time method directly:
 # sudo hwclock --set --date="04/15/15 16:19" (月/日/年 时:分:秒)
 
Common command parameters for hardware clocks

Command Parameters Description
-r,–show Read and print the hardware clock (read hardware clock and print result)
-s,–hctosys Synchronizing the hardware clock to the system clock (set the time from the hardware clock)
-w,–systohc Synchronizing the system clock to the hardware clock (set the hardware clock to the current system time)

Linux system time and hardware time settings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.