Modify the time zone and NTP time synchronization of centos

Source: Internet
Author: User
Tags time zones

When we use the centos system, problems may occur frequently in the time zone, and sometimes errors may occur after the change. Next we will learn a way to change this situation. If you are not using centos, run the yum install NTP command.

Then: ntpdate us.pool.ntp.org.
VPs may have restrictions and Problems

Ntpdate [1449]: Can't adjust the time of day: operation not permitted

Ntpdate [1, 9787]: The NTP socket is in use, exiting

Note: exclusive physical machines do not have this problem. Therefore, it is inferred that VPs is restricted and occupied. Therefore, the time cannot be modified. In theory, the physical host has already been synchronized. You only need to set the time zone.

Because the centos system is re-compiled with the source code of rhAS, many places are exactly the same.

The Time Zone of rhas5 exists as a file. The current time zone file is in/etc/localtime.

So where are files stored in other time zones?

Under/usr/share/zoneinfo

We use UTC + 8, Beijing, and Shanghai time.

# Cp-F/usr/share/zoneinfo/Asia/Shanghai/etc/localtime
# Reboot

After the restart, view the time in date, view the current time zone date-R, view/modify the Linux time zone and time

I. Time Zone

1. view the current time zone
Date-R

2. Modify the time zone
Method (1)
Tzselect
Method (2) Limited to RedHat Linux and centos Systems
Timeconfig
Method (3) applicable to Debian
Dpkg-reconfigure tzdata

3. Copy the corresponding time zone file, replace the centos System Time Zone file, or create a link file.
CP/usr/share/zoneinfo/$ main Time Zone/$ Time Zone/etc/localtime
Available in China:
CP/usr/share/zoneinfo/Asia/Shanghai/etc/localtime

Ii. Time

1. view the time and date
Date

2. Set the time and date
Set the centos system date to the June 10, 1996 command
Data-s 06/22/96
Set the centos system time to 01:52:00 P.M..
Date-s 13:52:00

3. Write the current time and date to the BIOS to prevent failure after restart
Hwclock-W

Related Article

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.