#!/bin/sh
# Get time from ntp server, one time, when inet up
 
while (true) do
 
 GATEWAY=`ip route show | grep 'default' | awk '{print $3}' | cut -d$'\012' -f1`
 
 if [ "a$GATEWAY" != "a" ] ; then
 
  ntpdate ntp1.inrim.it ntp2.inrim.it
 
  break
 
 fi
 
 sleep 10
 
done
Retrieved from "http://www.zoros.org/wiki/index.php?title=Ntpsync.sh_source_code"