Skip to content

Instantly share code, notes, and snippets.

@michaelkarrer81
Last active May 28, 2020 08:13
Show Gist options
  • Save michaelkarrer81/c8afcc3f74b7f94a1bf9918e3af595f6 to your computer and use it in GitHub Desktop.
Save michaelkarrer81/c8afcc3f74b7f94a1bf9918e3af595f6 to your computer and use it in GitHub Desktop.
[ntp cheat sheet] Network Time Protocoll Cheat Sheat #ntp #time #saltstack
https://www.redhat.com/en/blog/avoiding-clock-drift-vms
# https://www.ntp.org/
# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s1-checking_the_status_of_ntp
# http://www.satsignal.eu/ntp/NTPandMRTG.html
# https://exchange.nagios.org/directory/Plugins/Network-Protocols/NTP-and-Time
# https://www.redhat.com/en/blog/avoiding-clock-drift-vms
# To check if ntpd is configured to run at system start
chkconfig --list ntpd
# To check if ntpd is running
ntpq -p
# To obtain a brief status report from ntpd
ntpstat
# Common ntp and time commands
# ----------------------------
salt -G "kernel:Linux" cmd.run 'service ntp status'
salt -G "kernel:Linux" cmd.run 'service ntp restart'
salt -G "kernel:Linux" cmd.run 'hwclock --debug'
salt -G "kernel:Linux" cmd.run 'date'
salt -G "kernel:Linux" cmd.run 'ntptime'
salt -G "kernel:Linux" cmd.run 'timedatectl status'
salt -G "kernel:Linux" cmd.run 'ntpq -p'
# Check the time between to two servers
# -------------------------------------
# This will compate the time on the calling host to the time at the host given to ntpdate
salt -G "kernel:Linux" cmd.run 'ntpdate -q -u sosync2.datadialog.net'
salt -G "kernel:Linux" cmd.run 'ntpdate -q -u 192.168.37.1'
salt -G "os:Ubuntu" cmd.run 'ntpdate -q -u sosync2.datadialog.net'
salt -G "os:Ubuntu" cmd.run 'ntpdate -q -u 192.168.37.1'
# Force the system to use ntp time again
# --------------------------------------
# Stop the ntp service first
salt -G "os:Ubuntu" cmd.run 'service ntp stop'
# Run ntpd to force system time updates -g Allow the first adjustment to be Big -q Set the time and quit
salt -G "os:Ubuntu" cmd.run 'ntpd -qg'
# Restart the ntp service again
salt -G "os:Ubuntu" cmd.run 'service ntp start'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment