When ntpdate is used in linux

Source: Internet
Author: User
Article Title: When linux uses ntpdate for network calibration. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

At present, there are two time points on the Linux system, one is the Linux system, and the other is the BIOS time (the real hardware record time )! We can use the date command to manually modify the current host Time. However, the date command only modifies the Linux time. we also need to use the hwclock command to update the BIOS time! Hwclock [-rw]

-R: view the current BIOS time

-W: write the current linux system time to the BIOS. after we finish the Linux time, we also need to use hwclock-w to update the BIOS time, because the system will re-read the time from the BIOS during each boot, BIOS is an important time basis. 1. automatic network calibration at startup:

Vi/etc/rc. d/rc. local

/Usr/sbin/ntpdate-u 192.168.0.2 192.168.0.3 192.168.0.4;/sbin/hwclock-w 2. set the scheduled task

Crontab-e

10 5 * root ntpdate 192.168.0.2; hwclock-w

In this way, the network school is automatically started at every day.

Ntpdate command: set the local date and time by polling the specified NTP server that determines the correct time. It obtains some samples from each specified server, and applies the standard NTP clock filter and selection algorithm to select the best sample. The ntpdate command uses the following method to adjust the time:

* If it determines that the clock deviation exceeds 0.5 seconds, it sets the clock time by calling the settimeofday subroutine. This is the preferred method at the boot time.

* If it determines that the clock deviation is less than 0.5 seconds, it will adjust the clock time by calling the adjtime subroutine and offset. This method tends to sacrifice some stability to keep the drift clock more accurate.

When you run the ntpdate command with rules from the cron command rather than by running a daemon, the execution every hour or two hours can ensure sufficient time accuracy to avoid clock adjustment. 48 */1 ***/usr/sbin/ntpdate-u 172.16.58.40 172.16.58.14 172.23.32.142 172.24.18.141 172.24.147.11

1 1 ***/sbin/hwclock-w considerations:

1. using many servers can greatly improve the reliability and accuracy of the ntpdate command. Although you can use a single server, you can achieve better performance by providing at least three or four servers.

2. if an NTP server daemon similar to the xntpd daemon is running on the same host, the command rejects ntpdate setting.

3. you must have the root permission to run this command on the host. Note that the accuracy and reliability of ntpdate depend on the number of servers, the number of poll for each running of ntpdate, and the interval between running. Ntpdate can be manually run as needed to set the host clock, or run from the host startup script and set the clock during boot. In some cases, it can be used to set the clock before the NTP daemon xntpd is started. You can also run ntpdate from the cron script. However, it is important to note that ntpdate, which contains artificially generated cron scripts, cannot replace the NTP daemon. The latter uses advanced algorithms to improve accuracy and reliability while minimizing resource usage. Finally, because ntpdate does not control the host clock frequency like xntpd, the accuracy of ntpdate is very limited.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.