Enterprise Software

Dealing with inaccurate real-time clocks

If you've ever checked the clocks on your servers, you may have noticed that they can vary widely from server to server. In this Daily Feature, Brien Posey shows you how to synchronize time on your Windows NT servers.


A few weeks ago, I was faced with a situation in which I was unable to get two Microsoft Exchange Servers to replicate directory information between each other. As you may know, Exchange’s intersite directory replication is the process by which Exchange Servers share basic information with one another. Although replication is simple to configure, this time I just couldn’t make it work.

To make a long story short, five hours into the troubleshooting process I glanced at the clock in Windows’ system tray and discovered the time was wrong. After correcting the date and time, replication began to work immediately.

Incorrect time can cause severe problems on today’s networks, especially in environments in which such applications as mail servers or financial programs depend on an accurate timestamp. Unfortunately, the problems caused by inaccurate time clocks are becoming more widespread. I’ve seen dozens of computers whose real-time clocks tend to run either very slow or very fast. In fact, some of these clocks may lose a couple of hours each day.

If you have an Internet connection, you can use an NTP (Network Time Protocol) client program to synchronize the servers and workstations on your network with an external source. But what do you do if you don’t have an Internet connection? How do you maintain consistent time on your network? Fortunately, there’s another way around the problem if you do find yourself having to deal with PCs with slow time clocks.

The solution
The trick is to write a simple, one-line batch file that synchronizes the real-time clock with a server with a real-time clock that’s known to be accurate. The source server can be one that is synchronized with the Internet or one you decide is accurate enough to provide time for your network.

You can create the batch file with any text editor. All you have to include in the file is the following command:
NET TIME \\server /SET /YES

You issue this command from the workstation or server that needs to update its time. In this command, you replace \\server with the name of the server that has the proper time. The /SET parameter tells your PC to synchronize its clock with the server’s clock. Finally, the /YES parameter tells the PC not to pause and ask for confirmation when the clock is reset.

Once you’ve created the batch file, you must decide how often it should be run. On a Windows NT server, you can use the Windows Task Scheduler to run the batch file every few hours if the server’s clock is really fast or slow. If the clock is just a little fast or slow, you might consider embedding the batch file command in each user’s login script so that the clock is resynchronized at each login.
The authors and editors have taken care in preparation of the content contained herein but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.

Editor's Picks