SNTP and NTP use the same protocol on the wire “Ethernet Time Server” messages to compute accurate times. The difference is in the application that is running on each PC. The difference is in how the time diff is calulated. NTP is much more complex and thus accurate then SNTP. SNTP only keeps track of 1 server and NTP can triangulate between many servers.
NTP servers and NTP clients use the same socket for communication. So when you update the localtime, you need to turn off the NTP server for a moment.
NTP servers, hold time and can give their time to NTP clients. NTP clients check their time with NTP servers, and change their own time to try and match the servers time.
NTPDATE is used to adjust time with NTP servers.
SNTP is used to adjust time with SNTP servers.
You can use SNTP and NTP servers interchangeably. So you can use SNTP to update off an NTP servers time.
Here is a good explanation of the way they work with each other:
SNTP RFC 2030:
SNTP Version 4 is designed to coexist with existing NTP and SNTP Version 3 clients and servers, as well as proposed Version 4 clients and servers. When operating with current and previous versions of NTP and SNTP, SNTP Version 4 requires no changes to the protocol or implementations now running or likely to be implemented specifically for NTP ir SNTP Version 4. To a NTP or SNTP server, NTP and SNTP clients are undistinguishable; to a NTP or SNTP client, NTP and SNTP servers are undistinguishable.
There are 2 types of time adjustments. Try to jump the time to the new time (settimeofday), or skew the time with minor adjustments to final time (adjtime).
Running NTP server and NTPDATE client for updates
I list several methods, based on if you want to log using bash3 or bash4 methods.
Command options:
-s is for logs to go to syslog instead of stdout -b uses settimeofday instead of adjtime (skew time), which is better for when the system boots up without -b it uses adjtime if less then 0.5 second diff, and settimeofday if more then 0.5 second diff
COMMANDS WHILE SYSTEM IS UP
# if system is booting
/etc/init.d/ntp stop ntpdate -sb time.nist.gov /etc/init.d/ntp start
# if system still running
/etc/init.d/ntp stop ntpdate -s time.nist.gov /etc/init.d/ntp start
To log:
# if system is booting
/etc/init.d/ntp stop ntpdate -sb time.nist.gov 2>&1 | tee -a /var/log/timesync /etc/init.d/ntp start
# if system still running
/etc/init.d/ntp stop ntpdate -s time.nist.gov 2>&1 | tee -a /var/log/timesync /etc/init.d/ntp start
To log Or on bash4:
# if system is booting
/etc/init.d/ntp stop ntpdate -sb time.nist.gov |& tee -a /var/log/timesync /etc/init.d/ntp start
# if system still running
/etc/init.d/ntp stop ntpdate -s time.nist.gov |& tee -a /var/log/timesync /etc/init.d/ntp start
NTP RCLOCAL SCRIPT FOR BOOT
If you want to put this in an rc.local script:
To do on system startup in rc.local:
( /etc/init.d/ntp stop until ping -nq -c3 8.8.8.8; do echo "Waiting for network..." done ntpdate -s time.nist.gov /etc/init.d/ntp start )&
On boot actually better to use -b as it setstimeofday
( /etc/init.d/ntp stop until ping -nq -c3 8.8.8.8; do echo "Waiting for network..." done ntpdate -bs time.nist.gov /etc/init.d/ntp start )&
Lets logs using bash3 methods as well
( /etc/init.d/ntp stop until ping -nq -c3 8.8.8.8; do echo "Waiting for network..." done ntpdate -bs time.nist.gov 2>&1 | tee -a /var/log/timesync /etc/init.d/ntp start )&
Or log with bash4
( /etc/init.d/ntp stop until ping -nq -c3 8.8.8.8; do echo "Waiting for network..." done ntpdate -bs time.nist.gov |& tee -a /var/log/timesync /etc/init.d/ntp start )&
SNTP – simple network time protocol
Note below I use an NTP timeserver locally on the machine, but SNTP to get time from time server
Command line options:
-r: indicates that the system clock should be reset by settimeofday. Naturally, this will work only if the user has enough privilege. -a: indicates that the system clock should be reset by adjtime. Naturally, this will work only if the user has enough privilege. -P prompt: sets the maximum clock change that will be made automatically to maxerr. Acceptable values are from 1 to 3600 or no, and the default is 30. If the program is being run interactively in ordinary client mode, and the system clock is to be changed, larger corrections will prompt the user for confirmation. Specifying no will disable this and the correction will be made regardless.
commands For sntp:
By timeofday change – while system is booting
/etc/init.d/ntp stop sntp -P no -r us.pool.ntp.org /etc/init.d/ntp start
By adjtime change – good is system is running
/etc/init.d/ntp stop sntp -P no -a us.pool.ntp.org /etc/init.d/ntp start
commands for sntp on rc.local (for boot):
We will use the method that is good while booting -r, which just sets time of day with settimeofday instead of adjtime (which skews)
To log with bash3 methods:
( /etc/init.d/ntp stop until ping -nq -c3 8.8.8.8; do echo "Waiting for network..." done sntp -P no -r us.pool.ntp.org 2>&1 | tee -a /var/log/timesync /etc/init.d/ntp start )&
To log with bash4 methods:
( /etc/init.d/ntp stop until ping -nq -c3 8.8.8.8; do echo "Waiting for network..." done sntp -P no -r us.pool.ntp.org |& tee -a /var/log/timesync /etc/init.d/ntp start )&