修改linux服务器的时区

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

 

ntpdate 1.asia.pool.ntp.org

如果出现如下错误

21 Jul 01:00:06 ntpdate[21331]: the NTP sket is in use, exiting

则停止systemctl stop ntpd

ntpdate 1.asia.pool.ntp.org

 

 

vim /etc/ntp.conf

注释掉所有的restrict开头的配置

修改restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

为:restrict 192.168.10.40 mask 255.255.255.0 nomodify notrap

将所有server配置进行注释

添加下面两行内容

server 127.127.1.0

fudge 127.127.1.0 stratum 10

启动ntp服务---应该不用启动

systemctl start ntpd

systemctl enable ntpd

 

 

vim /etc/ntp.conf

添加server 192.168.10.40

执行:ntpdate 192.168.10.40

开机自启

systemctl enable ntpd

systemctl start ntpd

 

 

每两2小时同步一次

ntp服务器

0 */2 * * * ntpdate 1.asia.pool.ntp.org
0 */2 * * * hwclock -w

需要同步的时间

0 */2 * * * ntpdate yct44.yunchetong.com
0 */2 * * * hwclock -w

posted @ 2020-07-21 02:39  binjia  阅读(309)  评论(0编辑  收藏  举报