The system time In Debian is eight hours faster than the normal time.

Source: Internet
Author: User

First, configure the time zone. In the past, Debian had a better time zone Configuration tool called tzconfig, And now it does not exist. However, it is easy to configure the time zone, mainly including two files:

/Etc/localtime

/Etc/timezone

The timezone file is a text file, which only needs to write a line of its own time zone. Here we are Shanghai, Asia/Shanghai. Who knows why it is not Beijing ?). The type of the localtime file is unclear, and some timezone data is written in it, which can be copied from the system's built-in Time Zone file at:/usr/share/zoneinfo

Find the localtime copied from the Shanghai directory to/etc. Some people say that a connection is also possible, which can ensure that the system data does not need to be managed when there is a change.

Set the time zone and determine the Linux time scheme. Linux supports the UTC Time, Coordinated Universal Time, that is, the Time on the primary meridian, that is, the Time on the global coordination, and the GMT when the Greenwich Mean Time is earlier) the difference seems to be that it is averaged by multiple atomic clocks. In the/etc/default/rcS file, whether or not the system uses UTC is set, and UTC = yes is used.

The computer has its own time, that is, the hardware time, hard clock, that is, the time in the BIOS, And the shutdown will not be lost. This time will be read when the computer starts. If this time is set to UTCGMT), that is, the time in the place of London, you must set UTC = yes in the rcS file, and vice versa.

In short, there are two correct settings:

BIOS = local time, UTC = no

BIOS = UTC time, UTC = yes

Generally, the BIOS is set to the local time. This is because if a dual system is installed, Windows does not seem to understand utc, and the problem may occur. At this time, UTC = no.

If everything goes well, the time displayed after entering Linux should be correct. However, many machines, including this 640 m instance, are still incorrect. Instead, they ran eight hours ahead of the correct time. The problem lies in the hardware reading time in Linux.

The hwclock command is used to read the hardware in Linux:

Hwclock -- show: displays the hardware time.

Hwclock -- systohc: Write System Time to hardware

Hwclock -- hctosys: Write hardware time to system time

When a problem occurs, hwclock commands cannot be run successfully. errors are often as follows:

Select () to/dev/rtc to wait for clock tick timed out

That is, it cannot read/dev/rtc, that is, the hardware time. This is because of the problem between the BIOS Processing Method of some machines and the rtc kernel module of Linux.

Linux has three other such modules, rtc/genrtc/rtc_dev, which seems to be a newer one, while debian usually uses the old rtc module; however, Dell, ibm, acer, and other vendors may all use new BIOS. Such BIOS and rtc may not be used. If the above timeout problem occurs, there are two solutions:

1. Add a parameter to hwclock, -- directisa, that is:

Hwclock -- directisa -- show

If the operation is successful, this method is feasible. Add this parameter as the default hwclock parameter. After debian 4.0, you can directly add a row in/etc/default/rcS:

HWCLOCKPARS = "-- directisa"

Before 4.0, you may only be able to add it in the hwclock STARTUP script,/etc/init. d/hwclock. sh, replace "/sbin/hwclock" with "/sbin/hwclock -- directisa ". In the debian sid, the first line of this script is actually HWCLOCKPARS =. You can also add parameters like that of the rcS.

2. Use other kernel rtc modules to test which module is easy to use:

# Modprobe rtc

# Hwclock -- show

# Rmmod rtc

# Modprobe genrtc

# Hwclock -- show

# Rmmod genrtc

# Modprobe rtc_dev

# Hwclock -- show

# Rmmod rtc_dev

If the time out is not displayed, it is easy to use. Then, you can stop the bad time in the blacklist, and add the useful one in the modules.

After using these two methods, hwclock should be able to work directly, that is, it can read the hardware time. With the correct utc settings, the restart time is correct.

In order to make the BIOS time more accurate, in addition to finding a precise time source, such as a CDMA mobile phone or GPS, you can use your fingers to accurately set the BIOS time, you can also use hwclock to write accurate time to the BIOS. The previous method can be used with a few seconds of error, and the other method is less than one second.

Install the ntpdate package. It can read the correct time from the time server. The precision is still very high:

Aptitude install ntpdate

Ntpdate pool.ntp.org

At this time, the system time is already ntp time, which is quite accurate. Write it into the hardware:

Hwclock -- systohc

In this way, the BIOS time is very accurate. No network is available after the instance is started, and ntpdate cannot be run properly.

The key points here are: bios time, utc setting, rtc module, hwclock reading, and ntpdate pair.

In the old bug of Debian, we can see that because the system has multiple partitions, for example,/usr is divided separately, fsck will run on time, and thus cause problems that may take several hours, I don't know how to handle it.

Related Articles]

  • How to set the time in Linux
  • Set Linux time server in LAN
  • Server time modification methods

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.