When debugging a distributed system, logs are a good tool, such as logging with Log4j Records. However, if the time of each machine is inconsistent, it is not convenient to judge the order of each event. So time synchronization is useful, and the NTP protocol is widely known. This article explores how to use Win7 as NTP server,linux to do NTP client to make Win7 and Linux systems consistent in time.
1. Install NTP server on Win7
1 First download the latest NTP server from http://www.meinberg.de/english/sw/ntp.htm#ntp_nt_stable, the page below when writing this article, red part of the NTP server to be downloaded.
2) Direct installation (the default will be installed to the C:\Program FILES\NTP directory), the middle will appear to let you select a superior server (that is, the local time on its basis for periodic synchronization), the installation of the first to retain the default value.
When the installation is complete, the build Start menu is shown in the following illustration:
3 Open the C:\Program files\ntp\etc\ntp.conf file, modify the configuration: (can be accessed through the Explorer to open, from the Start menu "Edit NTP Configuration" Open when you want to open as an administrator to save changes)
The contents of my configuration file are as follows:
# NTP Network Time Protocol
# please CHECK this FILE carefully and MODIFY IT IF REQUIRED
# Configuration File created by Windows Binary distribution Installer Rev.: 1.26 MBG
# Please check http://www.ntp.org for additional documentation and background information
# Use Drift file
Driftfile "D:\develop\NTP\etc\ntp.drift"
# your local system clock, should is used as a backup
# (This is the useful if you need to distribute time no matter how good or bad it is)
Server 127.127.1.0
# but it operates at a high stratum level to let the clients know and force them to
# use ' Any other ' timesource they may have.
Fudge 127.127.1.0 Stratum 12
# Use a NTP server from the NTP Pool project (http://www.pool.ntp.org)
# Please note ' You need ' at least four different servers-at least protected
# one Falseticker. If you are rely on Internet time, it is highly recommended to add
# Additional servers here.
# the ' iburst ' keyword speeds up initial synchronization, please check the documentation for more details!
Server 0.asia.pool.ntp.org Iburst
Server 1.asia.pool.ntp.org Iburst
Server 2.asia.pool.ntp.org Iburst
Server 0.us.pool.ntp.org Iburst
Server 1.us.pool.ntp.org Iburst
Server 2.us.pool.ntp.org Iburst
# End of the generated ntp.conf---Please edit this to suite your needs
Note that the above time server can be replaced by finding available server IP from the Internet if it is not available.
4) to close the firewall. Note Be sure to turn off the Win7 operating system's own firewall. Otherwise, the "No Server suitable for synchronization found" error occurs when the client updates.
5) Restart the NTP Service from the Start menu.
6) Determine if the NTP service is working: Use the command ntpq-p
2 . Configure periodic and Win7 time synchronization
execution ntpdate on Linux systems 192.168.1.32 can Synchronizes native time with Win7 (192.168.1.32 as Win7 IP).
Note: When the NTPD process is running on Linux, the ntpdate command execution fails, and the NTP socket is in use, exiting. Executive: PS-AEF | grep NTPD finds the process and then kill it.
In general, we want to synchronize on a regular basis, using CRON implementations in Linux:
If I want to be able to use crontab-e edits every 10 minutes and Win7 sync time crontab work is as follows:
 */10 * * * * */usr/sbin/ntpdate 192.168.1.32&&/sbin/hwclock-w
The hwclock-w command above is used to update the BIOS time. which can be saved during the system restart time.