实现方法:
首先,安装yum install ntpdate时间同步命令组件
然后,将时间同步命令添加到 操作系统自启动文件 /etc/rc.local文件中 或者 /etc/rc.d/rc.local文件中
时间同步前应使用命令#cat /etc/php.ini | grep "timezone"查看系统时区值,先确保系统时区为PRC = People Republic of China(中华人民共和国),而后再进行系统时间同步操作
# 使用命令 sed -i '/date.timezone/idate.timezone=PRC/' /etc/php.ini 将系统时区设为PRC
# 然后使用命令 #vim /etc/rc.local 编辑 rc.local文件,在末行下面 加入“时间同步命令”
# 以下命令是同步北京时间
# PS: 如果上述时间服务器cn.pool.ntp.org失效则尝试时间服务器0.asia.pool.ntp.org以求达# 到同步北京时间目的(建议在rc.local文件配置双时间服务器, 确保时间同步动作的可靠 落 # 实)
# 以下命令是 将同步后的系统时间写入到硬件中
# hwclock -w
# :wq
知识拓展:ntpd ntpdate拓展