
ntptime Command in Linux
The ntptime command in Unix and Linux systems is used to display the current time along with various timekeeping parameters maintained by the kernel. It provides detailed information about the system's time status, including offset, frequency, and stability of the system clock.
The ntptime command is designed to be utilized with special kernels that support precision timekeeping as outlined in the document "A Kernel Model for Precision Timekeeping." This document details the kernel modifications and enhancements required to achieve high accuracy in system timekeeping.
The main function of the ntptime command is to read and display various time-related kernel variables. It achieves this by leveraging the ntp_gettime system call, which retrieves the current time along with the timekeeping parameters maintained by the kernel. These parameters include the current time, the maximum possible error, the estimated error, and other related metrics.
Table of Contents
Here is a comprehensive guide to the options available with the ntptime command −
Syntax of ntptime Command
The general syntax for the ntptime command is as follows −
ntptime options
ntptime Command Options
The following is detailed description of the ntptime command options in a table format −
Tag | Description |
---|---|
-M | switch to microsecond mode |
-N | switch to nanosecond mode |
-T tai_offset | set TAI offset |
-e est_error | Specify estimated error, in microseconds. |
-f frequency | Specify frequency offset, in parts per million. |
-h | Display help information. |
-m max_error | Specify max possible errors, in microseconds. |
-o offset | Specify clock offset, in microseconds. |
-r | Display Unix and NTP times in raw format. |
-s status | Set the status bits |
-t timeconstant | Specify time constant, an integer in the range 0-10. |
Examples of ntptime Command in Linux
In this section, we'll explore several practical examples of the ntptime command to showcase its versatility in accurately monitoring and adjusting the system's timekeeping parameters, ensuring precise and reliable time synchronization across various computing environments.
Display Current Time Parameters
To display the current time and timekeeping parameters, simply run −
sudo ntptime
This command shows the current time along with various time-related kernel variables like the estimated error, maximum error, and the status of the system clock.

Switch to Microsecond Mode
To switch the display to microsecond mode, you can use the following command −
sudo ntptime -M
This sets the output format to show timekeeping parameters in microseconds for more precise measurements.

Switch to Nanosecond Mode
To switch the display to nanosecond mode, simply run −
sudo ntptime -N
This sets the output format to show timekeeping parameters in nanoseconds, offering an even finer level of precision.

Set TAI Offset
To set the TAI (International Atomic Time) offset, you can use the "-T" option −
sudo ntptime -T 37
This sets the TAI offset to 37 seconds, which is used for precise timekeeping in coordination with atomic time standards.

Display Execution Time
To display the execution time of the ntptime command itself, use the "-c" option −
sudo ntptime -c
This provides the time taken to call the ntp_gettime system call, measured in microseconds.

Specify Estimated Error
To specify an estimated error in microseconds, run the following command −
sudo ntptime -e 5
This sets the estimated error to 5 microseconds, which helps in fine-tuning the system's timekeeping accuracy.

Specify Frequency Offset
To set the frequency offset in parts per million (ppm), you can use the "-f" option −
sudo ntptime -f 100
This sets the frequency offset to 100 ppm, adjusting the system clock's frequency error.

Display Help Information
To display help information for the ntptime command, simply run −
sudo ntptime -h
This shows the available options and usage information for the ntptime command.

Specify Maximum Error
To set the maximum possible error in microseconds, you can use the following command −
sudo ntptime -m 10
This sets the maximum error to 10 microseconds, ensuring the system clock stays within this error margin.

Display Unix and NTP Times in Raw Format
To print Unix and NTP times in raw format, you can use the "-r" option −
sudo ntptime -r
This displays the raw time data for both Unix and NTP times, providing low-level details of the system's timekeeping status.

Conclusion
The ntptime command is an essential tool for monitoring and managing system time in Unix and Linux environments. By providing detailed insights into the system's timekeeping status, the ntptime command helps administrators and users monitor and troubleshoot time synchronization issues.
This is particularly important in environments where precise timekeeping is critical, such as in financial systems, telecommunications, and scientific research.