Reasons for changes after Linux system restart

Source: Internet
Author: User
Tags cst time


Cause Analysis of system time changes
Linux has two types of time: system time and hardware time (BIOS time ).
The System reads the BIOS time every time it starts and assigns it to the system time. The system time will run independently, but the BIOS time will not change.


There are two representation formats in BIOS time. One is expressed in localtime and the other in UTC. You can run hwclock-debug to display the current hardware time.


The following describes the changes in system time in various situations:
1. When hwclock is set to localtime and UTC = true in/etc/sysconf/clock, the system time is 8 hours earlier than the BIOS time after the system is restarted.
2. When hwclock is set to localtime and UTC = false in/etc/sysconf/clock, the system time does not change relative to the BIOS time after restart.
3. When hwclock is set to UTC and UTC = true in/etc/sysconf/clock, the system time does not change relative to the BIOS time after the system is restarted.
4. When hwclock is set to UTC and UTC = false in/etc/sysconf/clock, the system time relative to the BIOS time is pushed 8 hours after the system is restarted.
As shown in:


 

UTC = true in/etc/sysconf/clock

UTC = false in/etc/sysconf/clock

Hardware time localtime

After the reboot, the system time is 8 hours earlier than the BIOS time.

System time unchanged

Hardware time UTC

System time unchanged

After the reboot, the system time is pushed 8 hours after the BIOS time


It can be seen that when the BIOS time settings are different from those in/etc/sysconf/clock, the system time at system startup is incorrect.


If there is a script to synchronize time, but it runs after the system is started. Although time synchronization can synchronize the system time to the correct time, an incorrect time interval may occur due to the incorrect system time setting, this interval may affect programs that depend on the system time.
Countermeasure: the root cause of this problem is that the hardware time type is inconsistent with the setting in/etc/sysconf/clock. Therefore, we will add hardware time synchronization in the time synchronization script to solve this problem.
Note:
UTC Time: the Universal Time Coordinated (UTC), that is, the Time of the 0 Time zone.
CST Time: CST China Standard Time UTC + China Coastal Time (Beijing Time), which is the localtime of our Time zone.






2. Time zone settings:
To ensure that the time is correct, set the time zone correctly. The correct setting is only for better time understanding and other maintenance.


Setting method:
1.
Manually set the time zone:
For example, set the UTC + 8 time


Ln-sf/usr/share/zoneinfo/Asia/Shanghai
/Etc/localtime


Edit ZONE = "Asia/Shanghai" in/etc/sysconfig/clock"


2.

Set using graphical commands
System-config-date (RedHat and CentOS only in most cases) or tzselect can be used as instructed by the command.


This article is taken from the wdlinux Forum http://www.wdlinux.cn/bbs/. For more information, see!


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.