Linux restore time with date change

Source: Internet
Author: User

These days found that the company's servers on the day faster than the real time, may lead to some irreversible problems, such as site points will be affected, log problems. With the date modified under the results of the immediate restoration of the problem, want to write hardware time, but the HWCLOCK–RW command has a problem, the specific operation is as follows:

[[Email protected] ~]# Date

Tue SEP 8 19:39:49 HKT 2015

[[Email protected] ~]# date 090811392015

Tue SEP 8 11:39:00 HKT 2015

[[Email protected] ~]# Date

Tue SEP 8 19:41:20 HKT 2015


[Email protected] ~]# Hwclock

Cannot access the Hardware Clock via any known method.

Use the--debug option to see the details of your search for an access method.

[Email protected] ~]# HWCLOCK-RW

You have specified multiple functions.

You can have only perform one function at a time.

[Email protected] ~]# Hwclock--debug

Hwclock from Util-linux-2.13-pre7

Hwclock:open OF/DEV/RTC failed, errno=19:no such device.

No usable clock interface found.

Cannot access the Hardware Clock via any known method.


[Email protected] ~]# vim/etc/syscyl.conf

Xen.independent_wallclock=1

[Email protected] ~]# hwclock-w--debug

Hwclock from Util-linux-2.13-pre7

Hwclock:open OF/DEV/RTC failed, errno=19:no such device.

No usable clock interface found.

Cannot access the Hardware Clock via any known method.

such as a series of operations or no effect, can not change the hardware time, write Bois. viewing system version Information

[Email protected] ~]# uname-a

Linux bogon 2.6.18-194.el5xen #1 SMP Tue Mar 22:01:26 EDT all x86_64 x86_64 x86_64 gnu/linux

[Email protected] ~]# cat/proc/version

Linux version 2.6.18-194.el5xen ([email protected]) (GCC version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Tue Mar 16 22:0 1:26 EDT 2010

"Reference Solution"

CentOS after installing the new kernel, the clock will always change after each reboot, making the system clock inaccurate. In the case of multiple operating systems (such as Windows and Linux dual systems), the time zone bias may also occur, and in any case set, will be restored after a reboot.

Computer designers set up a hardware clock on the motherboard, powered by a coin cell battery (cell) on the motherboard, which calculates the current time regardless of the number of seconds the computer is powered on. When the operating system starts, a program is called to read the hardware clock on the motherboard and is recorded in one (or a set) of variables in the operating system. Since then, the operating system's clock has gone out of the motherboard's hardware clock and started running separately (operating system clocks are driven by clock interrupts, unlike clocks on the motherboard).

No matter how fine the work is, the clock on the motherboard hardware and the clocks in the operating system maintained by the clock are somewhat error-less. So, the operating system calls another program every time it shuts down, writes the clock in the operating system to the motherboard hardware clock (Does this design indicate that the clock interrupt is more accurate than the motherboard hardware clock?). )。 Similarly, when the user modifies the clock within the operating system, it does not immediately write to the motherboard clock, but instead writes the hardware clock when the computer shuts down.

The hardware clock on the motherboard is presented as a device in the Linux operating system, and the device name is RTC (Real time Clock).

When compiling a new kernel using the old system (such as the CentOS 2.6.18 kernel), when the MKINITRD command is called, the/DEV/RTC is generated and placed in the Initrd-x.x.x.img file, and the new kernel generates the/DEV/RTC file itself. When kernel generates/DEV/RTC, it discovers that the device is already in the system and creates a/DEV/RTC0 device. At this point the Hwclock program will still read the RTC device, which will cause the device to read and write failure. Run the Hwclock–debug command to see the following output:

[Email protected] ~]# hwclock--debug hwclock from Util-linux-2.13-pre7 hwclock:open OF/DEV/RTC failed, errno=19:no su CH device. No usable clock interface found. Cannot access the Hardware Clock via any known method.

In fact, in response to this problem, the new version of the Hwclock has made adjustments. The new Hwclock will take the initiative to find the/DEV/RTC0 device to operate the motherboard hardware clock. As a result, the solution arises.

Hwclock also replace the peripheral application with the new. After the download is complete, compile the program:

1 2 3 4tar xfv util-linux-ng-2.17.tar.bz2 cd util-linux-ng-2.17./configure make

Once the compilation is complete, copy the generated Hwclock file to the specified location:

1CP hwclock/hwclock/sbin/

The hardware clocks of the operating system and the motherboard can then be synchronized.


This article is from the Linux OPS blog, so be sure to keep this source http://xuding.blog.51cto.com/4890434/1693115

Linux restore time with date change

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.