Created
July 23, 2019 04:50
-
-
Save nickpoulos/b519f9789ba367c54ca54b5b6b72bdc9 to your computer and use it in GitHub Desktop.
Bash NTP Update Script
This file contains 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