Linux system time setting of xen Virtual Machine

Source: Internet
Author: User
Tags cst time


Xen Virtual Machine linux system time settings have not been expected to become a problem, but because of the special requirements in the project, the server needs to be set to China Standard Time. So I studied it. It turns out that after the virtual machine is installed, the time setting part in the Virtual Machine script is generally set to localtime = 0 by default, that is, the time taken from the physical machine is the RTC of the virtual machine. Physical machines generally set the time to Beijing time. As a result, the time in the VM is always wrong. It turns out that the VM regards the Beijing time of the host as UTC. Therefore, the virtual machine time is always 8 hours different from that of the physical machine. When the project has strict requirements on server time and has to seriously face this problem, we have to carefully sort out various time setting methods for linux systems. Www.2cto.com first re-describes the time types on linux. Time types in linux generally include UTC, CST Time, and RTC. Their meanings are GMT (Greenwich Mean Time, Greenwich Mean Time ): it refers to the standard time of the Royal Greenwich Observatory on the outskirts of London, England, because the meridian is defined through the meridian there. UTC (Universal Time/Temps cordonné World Standard Time) CST (Central Standard Time National Standard Time, which is equivalent to the Central Standard Time ); china Standard Time ). It is actually Beijing time. Www.2cto.com GMT + 8 = UTC + 8 = CST, that is, the Chinese standard time is 8 hours faster than UTC. RTC (Real Time Clock)-a Real-Time Clock, also called CMOS Clock, is a chip on the PC motherboard. It is powered by a battery and can maintain the date and Time even if the system is powered off. Because it is independent from the operating system, it is also known as the hardware clock. It provides a timing standard for the entire computer and is the most primitive and bottommost clock data, in Linux, only RTC is used to obtain the time and date. However, by acting on the/dev/rtc device file, the process is also allowed to program RTC. By executing the/sbin/clock system program, the system administrator can configure the clock. There is no physical clock in the virtual machine, so the clock attribute is set by modifying the clock file. Set the Virtual Machine Time to be correctly displayed as the Chinese standard time if you want to reach the time in the virtual machine. These modifications are required: 1. first, modify the content of this file:/etc/sysconfig/clock to set the hardware clock to UTC time HWCLOCK = "-- utc". If you do not know the format of the time zone, you can see through the tzselect command tool. Www.2cto.com TIMEZONE = "Asia/Shanghai" 2. set the local time to CST, that is, the standard Chinese time ln-s/usr/share/zoneinfo/Asia/Shanghai/etc/localtime, the Virtual Machine time can be displayed as the correct CST time. Author: jackyyen

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.