Solve the problem of synchronizing time zone, date and time in CentOS 6 environment

888u

Last update at :2024-06-13,Edit by888u

Sometimes we install the system and the website building environment directly after installing the VPS hosting plan provided by the selected VPS service provider, but we will find that the published articles or sometimes the automatic execution script time set are different from our actual The time does not match. There are even some programs that need to compare the time difference with the local time before they can be accessed. If the current server time is before the local time, we may not be able to start the software and other problems.

So, if you encounter such a problem, or we can calibrate the time of our current VPS/server and adjust it to be consistent with the current local time regardless of whether there is such a time difference problem. Just at noon, a netizen needed to solve such a problem. Snail was operating in his CentOS6 environment and the records were shared.

First, display the current system time

date

The results displayed are as follows:

Thu Mar 26 02:30:59 EDT 2015

Second, change the time zone

View current time zone list

cd /usr/share/zoneinfo/ls

Here we can see all time zones

Here we show the time zone of a large area, but we need to find more detailed time, such as Beijing, Asia, then 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 we are asked if we want to replace, we just enter y and press Enter. This will change the time zone to the current time zone.

Third, modification date and time

date MMDDhhmmYYYY

If the current time and date of our date test are not correct, we can directly replace and update them after entering the above command.

MM: month number DD: date number hh: time in 24-hour format mm: minute 2 number YYYY: year

We can also synchronize the current system time and date with NTP (Network Time Protocol) all the time. Normally NTP should be installed into your Linux system by default, if our system does not have NTP, I can install NTP package with a simple command.

A – Install NTP to Ubuntu, Debian

apt-get updateapt-get install ntp

B – Install NTP to Fedora, Centos or redhat

yum install ntp

Then execute the ntpdate pool.ntp.org command to synchronize.

To summarize, through the above method we can keep the current VPS time consistent with our local time, so that whether we are debugging software or editing articles, the time is consistent with our current time.

Recommended site searches: US ASP space, virtual host ranking, US PHP host, free IP proxy, Korean server recommendation, domain name registration platform, free IP, agency filing, Hong Kong proxy server, Ministry of Industry and Information Technology website filing system,

Solve the problem of synchronizing time zone, date and time in CentOS 6 environment

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码