如何调整linux的时间为北京时间、修改linux 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@www.ctohome.com~]# date
Thu May  6 02:01:52 UTC 2010
[root@ www.ctohome.com ~]# rm -rf /etc/localtime
[root@ www.ctohome.com ~]# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@ www.ctohome.com ~]# date

Thu May 6 10:02:32 CST 2010 如果还是有些不对,那么需要用命令 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 校准后,如果时间还是不对,那么就是其他的问题了。如果是linux vps,那么可能就是母服务器的时间不对,没有办法了

猜你喜欢

转载自blog.csdn.net/zx711166/article/details/78839431
今日推荐