Created
October 6, 2014 15:00
-
-
Save jeremykendall/79aacd0eecf23d2276e8 to your computer and use it in GitHub Desktop.
Forcing a clock update using NTP: bash script edition
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/bash | |
# Forces an ntp update | |
# | |
# Based on SO user Martin Schröder's answer to "How to force a clock update | |
# using ntp?": http://askubuntu.com/a/256004/41943 | |
# Fail fast (set -e will bail at first error) | |
set -e | |
if [ "$EUID" -ne 0 ]; then | |
echo "ERROR: '$0' must be as root." | |
exit 1 | |
fi | |
service ntp stop | |
echo "Running 'ntpd -gq'" | |
ntpd -gq | |
service ntp start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment