Modify the time zone, date, and time synchronization method of CentOS 6 Environment

Source: Internet
Author: User
Tags time zones vps

Modify the time zone, date, and time synchronization method of CentOS 6 Environment

Sometimes we install the system in the vps host solution provided by the selected VPS service provider, and directly mount the website after installing the site building environment, however, we may find that the published articles or the automatic script execution time set in some cases does not match our actual time. Some programs can be accessed only when compared with the local time. If the current server time is earlier than the local time, we may not be able to start the software.

Therefore, if such a problem occurs, or we can calibrate our current VPS/Server regardless of the time difference, the adjustment is consistent with the current local time. At noon, a netizen needed to solve this problem. The old man was operating in his CentOS6 environment and recorded and shared the problem.

1. display the current system time

Date

The result is as follows:

Thu Mar 26 02:30:59 EDT 2015

2. Change the time zone

View the current time zone list

Cd/usr/share/zoneinfo/
Ls

Here we can see all the time zones

We will show the time zones for a wide range of regions, but we need to find more detailed time, such as Asia Beijing, so we need to continue to the Asia directory

Cd Asia

Ls

If we need to set the "Shanghai" time to the current time.

Cp/usr/share/zoneinfo/Asia/Shanghai/etc/localtime

Then, ask if we want to replace it. Enter y and press Enter. In this way, the time zone is changed to the current time zone.

3. Modify the date and time

Date MMDDhhmmYYYY

If date is used to test whether the current time and date are different from the current time, we can directly replace the update after entering the above command.

MM: number of months
DD: Date Number
Hh: The time in the 24-hour format.
Mm: Minute 2 digits
YYYY: Year

We can also synchronize the current system time and date with NTP (Network Time Protocol. Generally, NTP should be installed in your Linux system by default. If your system does not have NTP, I can use a simple command to install the NTP package.

A-install NTP on Ubuntu and Debian

Apt-get update
Apt-get install ntp

B-install NTP to Fedora, Centos or redhat

Yum install ntp

Then execute the ntpdate pool.ntp.org command for synchronization.

In summary, we can keep the current VPS time with our local time through the above method. In this way, the time is consistent with our current time for debugging software or editing articles.

The Fixed Link: http://www.laozuo.org/5562.html | old left blog

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.