The sntp4 command queries a Network Time Protocol (NTP) server and displays the offset time of the system clock with respect to the server clock.
sntp [ -h | -help | -? ] [ -v | -V | -W ] [ -q [-f savefile ] | [{-r | -a} [ -P prompt ] [-l lockfile] ] [-c count ] [-e minerr ] [-E maxerr ] [ -d delay | -x [separation ] [-f savefile] ] [-4 | -6 ] [-u] [address(es) ] ]
The sntp4 command is a Simple Network Time Protocol (SNTP) client used to query a Network Time Protocol (NTP) server and displays the offset time of the system clock with respect to the server clock. If you execute the sntp4 command logged in as a root to the system, the sntp4 command corrects the system offset time. The sntp4 command can be executed as an interactive command or from a script such as thecron job. The sntp4 command implements the SNTP protocol defined in the RFC-2030, which is a subset of the NTP protocol defined in the RFC-1305. The sntp4 command does not provide the full NTP implementation features such as sanity checks, access controls, security functions, and mitigation algorithms.
By default the sntp4 command displays the local date and time to the standard output in the following format:
1996 Oct 15 20:17:25.123 + 4.567 +/- 0.089 secs
where, + 4.567 +/- 0.089 secs indicates the time offset and error bound of the system clock with respect to the server clock.
If the NTP server address is explicitly specified in the sntp4 command, the sntp4 command sends a single message to the server and waits up to delay seconds for a unicast server message. If the NTP server address is explicitly specified in the sntp4 command, the sntp4 command does not send a message to the server and waits up to delay seconds for a broadcast server message.
Item | Description |
---|---|
-4 | Forces IP version 4 DNS resolution. |
-6 | Forces IP version 6 DNS resolution. |
-a | Slews the system clock to the correct time by using the UNIX adjtime system call. This option requires the root privilege. |
-c count | Sets the maximum number of NTP packets required to count. The acceptable values for this option ranges from 1 to 25 in unicast mode, and 5 to 25 in broadcast mode. The default value is 5 in unicast mode, and broadcast mode. |
-d delay | Sets the maximum waiting time in broadcast mode to delay seconds. The acceptable values for this option ranges from 1 to 3600. The default value is 15 in unicast mode, and the default value is 300 in broadcast mode. |
-e minerr | Sets the minimum offset to minerr seconds. The measured offset values lesser than the values set by this option are ignored. The acceptable values for this option ranges from 0.001 to 1 in unicast mode The default value is 0.1 in unicast mode, and the default value is 0.5 in broadcast mode. |
-E maxerr | Sets the maximum offset to maxerr seconds. The measured offset values greater than the values set by this option are ignored. The acceptable values for this option ranges are from 1 to 60. The default value is five. |
-f savefile | Stores records of previous packets when used with the -x option, which speeds up re-calculating the drift after SNTP has to be re-started (e.g. because of network or server outages). In order to restart the data, sntp must be restarted reasonably soon after it died (within a few times the value of separation), with the same value of the -c option, the same value of separation, and in the same mode (i.e. broadcast or client), though the NTP servers need not be the same for client mode, and with compatible values of other settings. Note that the file will be created with the default ownerships and permissions, using standard C facilities. The default is installation-dependent, but will usually be in the /etc/sntp.state file. |
-h, -help | Displays usage information. |
-l lockfile | Sets the name of the lockfile to ensure that there is only one instance of the SNTP running at a time. The default value is installation dependent and is specified in the /etc/sntp.pid file. |
-P prompt | Sets the maximum automatic offset value to maxerr seconds. The acceptable values ranges from 1 to 3600, or no. The default value is 30. If the sntp4 command is run interactively, the measured offset values greater than 30 will prompt the user for confirmation. Specifying no will disable this and the correction will be made regardless. |
-q | Indicates that the sntp4 command should query a daemon savefile maintained by the SNTP. This option does not require any privileges. The option does not modify the savefile nor the system clock. |
-r | Steps the system clock to the correct time of the UNIX settimeofday system call. This option requires the root privilege. |
-u | Uses an unprivileged port. |
-v | Writes diagnostic messages and a limited amount of tracing to standard error. The -v, -V and -W give increasing levels of detail. |
-x separation | Causes the program to run as a daemon (i.e. forever), and to estimate and correct for the clock drift. separation sets the minimum time between calls to the server in minutes if a NTP host is specified, and between broadcast packets if not. Acceptable values are from 1 to 1440 (a day), and the default (if -x is specified but separation is omitted) is 300. |
Item | Description |
---|---|
address | NTP server address. |
Item | Description |
---|---|
0 | Successful completion. |
>0 | An error occurred. |
Access Control: The user must be a member of the system group.
Item | Description |
---|---|
/usr/sbin/ntp4/sntp4 | Contains the sntp command |
/usr/sbin/sntp --> /usr/sbin/ntp3/sntp | Default Symbolic link to NTP version 3 binaries from /usr/sbin directory. |
To get the time offset of the system clock relative to the server (9.41.254.24) clock, enter the following command:
sntp 9.41.254.24
The following output appears:
2009 Feb 25 12:28:38.00620 - 0.00679 +/- 0.31077 secs