ntpdatesync.sh 333 B

1234567891011121314151617
  1. #!/bin/sh
  2. cat /etc/asterisk/ntp.conf |grep =|tr -d " " > /tmp/ntp.conf.tmp
  3. . /tmp/ntp.conf.tmp
  4. #killall ntpd
  5. /etc/init.d/ntp stop > /dev/null
  6. TZ=$TZNAME
  7. if ntpdate $NTPserver 1> /dev/null ;then
  8. echo "Sync success!"
  9. /etc/init.d/hwclock.sh stop
  10. else
  11. echo "Sync failed!"
  12. fi
  13. echo `date "+%x %R"`
  14. /etc/init.d/ntp start > /dev/null