forked from qrpike/CentOS-6-Quick-Install-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installNTP.sh
34 lines (24 loc) · 772 Bytes
/
installNTP.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
echo 'installing and configuring NTP'
yum install -y wget ntp
chkconfig ntpd on
ntpdate pool.ntp.org
/etc/init.d/ntpd start
# Set timezone
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
echo 'NTP is setup and configured'
echo 'Below should be the correct date:'
date
# Replace centos pool with regular NTP pool
sed -i 's/centos.pool.ntp.org/pool.ntp.org iburst/g' /etc/ntp.conf
# Add this to not fail on big time gaps ( VMs that resume/pause )
echo "tinker panic 0" >> /etc/ntp.conf
# Create a script to update time.
cat >/usr/bin/updatetime <<EOL
/etc/init.d/ntpd stop
ntpdate pool.ntp.org
/etc/init.d/ntpd start
EOL
# now we can just run "updatetime" to restart and sync time servers:
chmod +x /usr/bin/updatetime