How to Change the Time Zone on a Linux VPS

How to Change the Time Zone on a Linux VPS

Many programs may have time zone errors, so how do you adjust the VPS time zone to the current time zone?
Under ssh:

1. Check system time

date

Will display: Tue Apr 1 16:27:26 CEST 2014

2. Change the time zone

cd /usr/share/zoneinfo/
ls

The following will be displayed:
Africa Canada GB Indian Mexico ROK iso3166.tab
America Chile GB-Eire Iran NZ Singapore posix
Antarctica Cuba GMT Israel NZ-CHAT Turkey posixrules
Arctic EET GMT+0 Jamaica Navajo UCT right
Asia EST GMT-0 Japan PRC US zone.tab
Atlantic EST5EDT GMT0 Kwajalein PST8PDT UTC
Australia Egypt Greenwich Libya Pacific Universal
Brazil Eire HST MET Poland W-SU
CET Etc Hongkong MST Portugal WET
CST6CDT Europe Iceland MST7MDT ROC Zulu

Search for your country or region. For China, select Asia.

/usr/share/zoneinfo/Asia
ls

The following areas are displayed:
Aden Choibalsan Irkutsk Macau Rangoon Thimbu
Almaty Chongqing Istanbul Macau Riyadh Thimphu
Amman Chungking Jakarta Magadan Riyadh87 Tokyo
Anadyr Colombo Jayapura Makassar Riyadh88 Ujung_Pandang
Aqtau Dacca Jerusalem Manila Riyadh 89 Ulaanbaatar
Aqtobe Damascus Kabul Muscat Saigon Ulan_Bator
Ashgabat Dhaka Kamchatka Nicosia Sakhalin Urumqi
Ashkhabad Dili Karachi Novokuznetsk Samarkand Vientiane
Baghdad Dubai Kashgar Novosibirsk Seoul Vladivostok
Bahrain Dushanbe Kathmandu Omsk Shanghai Yakutsk
Baku Gaza Katmandu Oral Singapore Yekaterinburg
Bangkok Harbin Kolkata Phnom Penh Taipei Yerevan
Beirut Hebron Krasnoyarsk Pontianak Tashkent
Buy a deal for your business
Brunei Hong Kong Kuching Qatar Tehran
Calcutta Hovd Kuwait Qyzylorda Tel_Aviv

Of course we chose Chongqing or Shanghai.
The following sets Chongqing time as local time.

cp /usr/share/zoneinfo/Asia/Chongqing /etc/localtime

This changes the time zone to China.

3. Synchronize time

Install ntp.

Installation on Ubuntu and Debian:

apt-get update && apt-get install ntp

Installation on Fedora, Centos, and RedHat:

yum install ntp

Sync time:

ntpdate pool.ntp.org

<<:  Srvify: $9.71/month/512MB/100GB space/1TB traffic/XEN

>>:  nationserver: $7/year/128MB/10GB space/250GB bandwidth/OpenVZ

Recommend

Analyze your website with Google Webmaster Tools

Google Webmaster Tools is officially called Webma...

RA4W: $15/year/512MB RAM/20GB SSD space/500GB bandwidth/OpenVZ/UK

RA4W, a company registered in Nevada, USA, provid...

StableHost registration and renewal discount code

StableHost first-time purchase discount code: Lon...

Automatically install OpenLiteSpeed ​​on CentOS7

Based on official OpenLiteSpeed. Official script:...

Serveroffer: €1.99/month/1.2GB memory/7GB space/2TB traffic/OpenVZ/Lithuania

Serveroffer is a Lithuanian hosting provider. It ...

Namecheap: SSL certificate discount, 5 years for only $29.95

NameCheap is a very good domain name registrar. T...

CycloneServers: $15/year/512MB memory/15GB space/1TB bandwidth/KVM/Los Angeles

CycloneServers, which has been introduced several...

VpsLot: $4.9/month/1GB/20GB space/500GB traffic/Xen/Chicago

VpsLot, a newly established American hosting comp...