登录SSH,输入date,查看时间。如果不是北京时间的话。输入以下两个代码:
rm -rf /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
再次输入date命令,如果时间还是不正确的话,
用ntpdate同步时间
ntpdate CentOS 安装方法:
yum -y install ntpdate ntp
ntpdate Ubuntu安装方法:
sudo apt-get install -y ntpdate ntp
安装ntpdate后
ntpdate cn.pool.ntp.org
如果这时出现no server suitable for synchronization found
解决办:
法命令行输入
service ntpd start
会看到Starting ntpd: [ OK ]
然后再使用
service ntpd status
看到ntpd (pid 1211) is running...
这个时候再使用这个命令
service ntpd start
最后,再重新输入
ntpdate cn.pool.ntp.org
同步北京时间。