Created
February 24, 2011 18:50
-
-
Save mostlygeek/842650 to your computer and use it in GitHub Desktop.
Runs ntpdate if the clock is off by more than 10 seconds. Useful for VMhosts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
DIFF=`ntpdate -q pool.ntp.org | awk '/offset ([-0-9\.]+) sec/ {i=int($10); print (i >= 0) ? i : 0 - i}'` | |
# set the date if the difference is > 10 seconds | |
if [ $DIFF -gt 10 ]; | |
then | |
echo -n "Time off by $DIFF seconds. Setting date ..." | |
sudo ntpdate pool.ntp.org | |
echo "one"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment