服务器时间同步脚本

我是把ntpdateup.sh这个脚本放在了/root目录下


[root@nhrnormal ~]# cat ntpdateup.sh 

#!/bin/bash


NTPFILE="/etc/ntp.conf"

NTPSERVER="192.168.20.37"

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


你可能感兴趣的:(服务器,同步脚本)