Advertisement
opexxx

installNTP.sh

Nov 24th, 2013
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.79 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. echo 'installing and configuring NTP'
  4.  
  5. yum install -y wget ntp
  6. chkconfig ntpd on
  7. ntpdate pool.ntp.org
  8. /etc/init.d/ntpd start
  9.  
  10.  
  11. # Set timezone
  12. rm -f /etc/localtime
  13. ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
  14.  
  15.  
  16. echo 'NTP is setup and configured'
  17. echo 'Below should be the correct date:'
  18. date
  19.  
  20. # Replace centos pool with regular NTP pool
  21. sed -i 's/centos.pool.ntp.org/pool.ntp.org iburst/g' /etc/ntp.conf
  22.  
  23. # Add this to not fail on big time gaps ( VMs that resume/pause )
  24. echo "tinker panic 0" >> /etc/ntp.conf
  25.  
  26. # Create a script to update time.
  27. cat >/usr/bin/updatetime <<EOL
  28. /etc/init.d/ntpd stop
  29. ntpdate pool.ntp.org
  30. /etc/init.d/ntpd start
  31. EOL
  32.  
  33. # now we can just run "updatetime" to restart and sync time servers:
  34. chmod +x /usr/bin/updatetime
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement