我是把ntpdateup.sh这个脚本放在了/root目录下
[root@nhrnormal ~]# cat ntpdateup.sh
#!/bin/bash
NTPFILE="/etc/ntp.conf"
NTPSERVER="192.168.20.*"
cat >${NTPFILE} <<EOF
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
server ${NTPSERVER} iburst
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
EOF
service ntpd stop
ntpdate ${NTPSERVER}
service ntpd start
[root@nhrnormal ~]# pwd
/root
本文转自aaa超超aaa 51CTO博客,原文链接:http://blog.51cto.com/10983441/1732967