Last active
February 28, 2018 14:26
-
-
Save ttran4040/aa5aba581c8061e6800d1681b55ac5a3 to your computer and use it in GitHub Desktop.
Update Vagrant Ubuntu Time
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
Copy and paste the above script into a text file (I’ve named mine force-ntp-update). | |
On the command line, call chmod a+x /path/to/force-ntp-update to allow all users to execute the command. | |
If you’re the only user who should be able to execute the command, change the above to chmod u+x /path/to/force-ntp-update. | |
Move the script somewhere in your path: mv /path/to/force-ntp-update /usr/local/bin. | |
``` | |
#!/bin/bash | |
# Forces an ntp update | |
# 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