Created
June 27, 2017 16:36
-
-
Save ZeroDeth/4c5a1f3e8262ede73fab53de2f3b18d0 to your computer and use it in GitHub Desktop.
Checks and ensures that the ntpd service is started and running, and sets it to start at system boot.
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 | |
# Check if ntp is installed, and, if not, install it. | |
if ! rpm -qa | grep -qw ntp; then | |
yum install -y ntp | |
fi | |
# Start ntpd if it's not already running. | |
if ps aux | grep -v grep | grep "[n]tpd" > /dev/null | |
then | |
echo "ntpd is running." > /dev/null | |
else | |
systemctl start ntpd.service > /dev/null | |
echo "Started ntpd." | |
fi | |
# Make sure ntpd is enabled on system startup. | |
systemctl enable ntpd.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment