centos7时间同步和时区设置

centos7时间同步和时区设置

安装ntp服务的软件包

yum install ntp

将ntp服务设置为缺省启动

systemctl enable ntpd

修改启动参数,增加-g -x参数,允许ntp服务在系统时间误差较大时也能正常工作

vi /etc/sysconfig/ntpd

启动ntp服务

service ntpd restart

将系统时区改为上海时间 (亦即CST时区)

ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

查看时间是否正确

执行

date

命令即可。

注:特殊情况下,3-5分钟生效,可重启系统立即生效

  

Talk is cheap, show me the code!
多说无用,给我看你的行动。
——林纳斯·托瓦兹 

 
原文地址:https://www.cnblogs.com/fanlinglong/p/6363031.html