#!/bin/sh # /etc/cron.hourly/clock-sync # a script to sync the clock to the network ntpd server source /etc/functions-internet #initialize variables and locations NTPDATE=/usr/sbin/ntpdate # insert the appropriate local box name; box should be listed in /etc/hosts to avoid DNS issues, otherwise use an actual IP address NTPSERVER=boxname # is this box running the ntp daemon? if yes then don't bother with syncing if [ "`ps ax | grep 'ntpd'`" = "" ] ; then # not running the ntpd, run an internet ping test. # if the LAN gateway server is not online then ntpd probably is not active Ping_Test &> /dev/null if [ "$PINGTEST" = "FAILED" ] ; then # not connected Exit_Script clock-sync fi # if we got a good internet ping test then the local ntpd server is online too: same box $NTPDATE -s $NTPSERVER &> /dev/null fi