Skip to content

Instantly share code, notes, and snippets.

@nickpoulos
Created July 23, 2019 04:50
Show Gist options
  • Save nickpoulos/b519f9789ba367c54ca54b5b6b72bdc9 to your computer and use it in GitHub Desktop.
Save nickpoulos/b519f9789ba367c54ca54b5b6b72bdc9 to your computer and use it in GitHub Desktop.
Bash NTP Update Script
#!/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