VPS(Virtual Private Server 虛擬專用服務器)技術,將一部服務器分割成多個虛擬專享服務器的一種服務。大多站長喜歡用美國的VPS,而美國的時間和時區和國內不同,那就需要通過SSH修改linux vps時間和時區。
大部分朋友都喜歡用美國的 VPS 主機,原因嘛,大家懂的。美國的vps大多都是國外的時間,讓我們的程序總是不適應。那么如何調整linux的時間為北京時間?修改linux vps的時間和時區,有什么辦法?
首先,需要ssh登錄vps或服務器。 date 命令可以查看時間和時區。然后輸入以下命令:
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
再date查看下時間和時區,時間是否正確了。如果已經正確,那么OK搞定。 SSH操作范例:
root@haochuangtest~]# date Thu May 6 02:01:52 UTC 2016 [root@haochuangtest ~]# rm -rf /etc/localtime [root@haochuangtest~]# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime [root@haochuangtest~]# date Thu May 6 10:02:32 CST 2016
如果還是有些不對,那么需要用命令 ntpdate stdtime.sinica.edu.tw 來校准時間。ntpdate stdtime.sinica.edu.tw 如果提示無此命令,那么需要先安裝 ntpdate
CentOS 安裝方法:
yum -y install ntpdate ntp
Ubuntu安裝方法:
sudo apt-get install -y ntpdate ntp
Ubuntu 系統
sudo apt-get install -y ntpdate ntp
校准后,如果時間還是不對,那么可能就是母服務器時間的問題了。