The recent change (in v3.8 ) of the hard-coded DAYTIME server in '/usr/bin/getTime.sh' does not seem to have been a great improvement. At least considering my own experience of the last few days. Clearly vitex would be right to claim
"I told you so".
Whilst I had stated in the same thread that a single user experience might not be applicable to everybody else, I also believe that a single hard coded value is less then ideal. After checking the
list again I'd like to suggest the following patch:
--- /usr/bin/getTime.sh
+++ getTime.sh
@@ -17,4 +17,7 @@
[ "x$1" = "x-p" ] && shift && PRINT=1
-NIST="$1";[ -z "$NIST" ] && NIST="time.nist.gov"
-R=$(nc "$NIST" 13 | grep "UTC(NIST)")
+NIST="$1"
+USTIMING_SERVERS="atl chi sj" # the whole list: "atl chi la lv nj ny pa sj"
+[ -z "$NIST" ] && NIST="nist1-$( echo "$USTIMING_SERVERS" \
+ | awk '{ srand(); n = int(rand() * NF) + 1; print $n }' ).ustiming.org"
+R=$( nc -w 3 "$NIST" 13 | grep "UTC(NIST)")
if [ -n "$R" ] ; then
@@ -26,3 +29,6 @@
fi
+ date
+else
+ echo "no response from $NIST" > /dev/stderr
+ exit 1
fi
-date
It tries to address the issue by: (1) picking randomly one out of several servers from the
US Time Server Foundation, (2) specifying a certain wait time (i.e. 3 seconds), (3) having a defined response (i.e. an error message and an 'exit') when not having received an answer, and (4) only showing the current time stamp when a reply was received.
Please note that I've limited the list of servers to only the three (i.e. Atlanta, Chicago and San Jose) from which I managed to get DAYTIME responses. But if other users are getting a different result I'd suggest to use a fuller list (see the comment in the same line). At least point (3) and (4) would allow the user to now be clear about the success or failure of the script execution.
EDIT: Minor correction by dropping the superfluous parameter in the 'rand()' function.