Force Time Synchronization hourly = Accurate Schedule starts

User avatar
JazJon

Posts: 397
Joined: Wed Jun 15, 2011 5:42 pm
Location: San Francisco

HTPC Specs: Show details

Force Time Synchronization hourly = Accurate Schedule starts

#1

Post by JazJon » Wed Apr 24, 2013 12:21 am

EDIT: Below the line is my original post. The windows method is not reliable, servers failed yet again. (confirmed manually syncing produced error time out) my time was off a few minutes.
So in summary, I give up on the built in Windows time sync. I installed http://www.timesynctool.com/

Works great! More fail safe options, and nice logs. I recommend TimeSyncTool. (free open source too)

I disabled the Windows Time Sync in Task Scheduler below.

____________________________________________________

I wanted to share a tip on how to force windows to synchronize the clock of your PC more often. The default is like every month'ish or so, and you'll notice the start/stop time of scheduled recordings often drifts a few minute off in between. (losing the beginning of a show)

Here's how! (works great for me, I set it to happen every hour at x:54)

It works for both Windows 7 and Windows 8

http://www.ali-inc.com/technical/196-sy ... often.html

Force Windows time synchronization more often
Last week we discussed how to setup synchronization with an external time source. This week we will learn how to make the syncs occur more often.

Why is this important?
In different environments I’ve seen windows time drift by 1-2 minutes in a single day depending on hardware resources. Windows does not provide any user facing or GUI options to change the clock-sync frequency. By default it is set for once a week on Sunday night. The AD PDC controls time for the entire domain. This schedule should be added to the PDC of a domain. It can also be used to sync any Vista or Win 7 client not on a domain.

What NOT to do: The Synchronize Time task
Do not edit the registry or change the default sync task in Scheduled Tasks.

W32TM.EXE Tool
W32TM.EXE is a tool for troubleshooting windows time service. If you run W32TM.EXE with a /RESYNC argument it will trigger a clock sync. That is if the Windows Time Service is already running. If you want to test it make sure Windows Time service is started.

What to Do: Create a new Task
We will setup two tasks. The first ensures that the Windows Time service is available. The second then runs W32tm.exe /resync as often as you like

1. Open the "Task Scheduler"

2. Open the Microsoft / Windows / Time Synchronization tree and click "Create Task"

Image

3. Give the task a new name. Mine is called "Sync Time"

4. Change the service to run under "LOCAL SERVICE" authority and check "run with highest privileges"

Image

5. Change Configure for: to your Operating System

6. Choose the time you want the task to run each day. I have chosen 7:00AM each morning. (EDIT, I checked the box to repeat the task every hour at x:54)

7. The task will run two commands so order is important. The first command ensures Windows Time service is running the second causes a manual sync

Set the first action to start a program, which is %windir%\system32\sc.exe with argument start w32time task_started
Set the second action to start a program, which is %windir%\system32\w32tm.exe with argument /resync

Image

8. You can check the status of the updates using the System Event Viewer. Look for events that reference the TIME SERVICE

____________________________________________________________________

P.S. The default server windows uses to change the time often times out. I have better results using the NIST servers (see below)

Image

EDIT:
I exported the task I created above so it's easy to import for someone else or if I rebuild my PC from scratch (see attached)
The UserId will be wrong so either fix it manually in taskschedule after you import this, or edit it before hand.
Attachments
Sync Time.zip
Time Sync.xml
(1.11 KiB) Downloaded 431 times
Last edited by JazJon on Sat May 11, 2013 6:06 am, edited 3 times in total.

foxwood

Posts: 1761
Joined: Fri Sep 07, 2012 3:43 pm
Location:

HTPC Specs: Show details

#2

Post by foxwood » Wed Apr 24, 2013 3:15 pm

You can also use the time servers that people vounteer through ntp.org.

The following command sets the Windows Time Service up to synchronize against a group of NTP servers, and ntp.org uses round robin DNS to share those requests out among over 700 NTP servers in the US. If you are based somewhere else in the world, you should replace .us with your own country code, so that you use an NTP server that's closer to you, and therefore should give a faster response.

w32tm /config /syncfromflags:manual /manualpeerlist:0.us.pool.ntp.org,1.us.pool.ntp.org,2.us.pool.ntp.org,3.us.pool.ntp.org


See http://www.ntp.org for more information.

User avatar
mcewinter

Posts: 999
Joined: Thu Jun 30, 2011 8:33 pm
Location: Chicago

HTPC Specs: Show details

#3

Post by mcewinter » Wed Apr 24, 2013 4:41 pm

I don't think servers are the problem. Windows tends to refuse to sync the time. I use the method JazJon posted and it's quite reliable.

User avatar
STC

Posts: 6808
Joined: Mon Jun 06, 2011 4:58 pm
Location:

HTPC Specs: Show details

#4

Post by STC » Wed Apr 24, 2013 5:23 pm

^+1

Although my HTPC's time drifts about 2 seconds a day so I sync every 24 hours.
By the Community, for the Community. 100% Commercial Free.

Want decent guide data back? Check out EPG123

User avatar
JazJon

Posts: 397
Joined: Wed Jun 15, 2011 5:42 pm
Location: San Francisco

HTPC Specs: Show details

#5

Post by JazJon » Tue Apr 30, 2013 7:24 am

My new Mac Mini was drifting as much as 3 minutes per hour at times. (can't figure it out) The hourly sync at x:54 seems to be working perfectly long term so far. If I notice it's not working even longer term, I'm going to guess I got flagged from the sync server I'm using for requesting the time update too often. (but so far so good) I'll add the pool method foxwood talked about if needed.

User avatar
STC

Posts: 6808
Joined: Mon Jun 06, 2011 4:58 pm
Location:

HTPC Specs: Show details

#6

Post by STC » Tue Apr 30, 2013 12:07 pm

JazJon wrote:My new Mac Mini was drifting as much as 3 minutes per hour at times. (can't figure it out)
Most probably the cause is a dodgy quartz crystal oscillator.
By the Community, for the Community. 100% Commercial Free.

Want decent guide data back? Check out EPG123

foxwood

Posts: 1761
Joined: Fri Sep 07, 2012 3:43 pm
Location:

HTPC Specs: Show details

#7

Post by foxwood » Tue Apr 30, 2013 12:20 pm

mcewinter wrote:I don't think servers are the problem. Windows tends to refuse to sync the time. I use the method JazJon posted and it's quite reliable.
Time.windows.com often fails to respond - I'm pretty sure it's a server problem, not a Windows issue, because I don't see those failures using other servers.

User avatar
holidayboy

Posts: 2840
Joined: Sun Jun 05, 2011 1:44 pm
Location: Northants, UK

HTPC Specs: Show details

#8

Post by holidayboy » Tue Apr 30, 2013 12:27 pm

STC wrote: Most probably the cause is a dodgy quartz crystal oscillator.
Either that or the dilithium matrix needs to be re-initialised.
Rob.

TGB.tv - the one stop shop for the more discerning Media Center user.

User avatar
STC

Posts: 6808
Joined: Mon Jun 06, 2011 4:58 pm
Location:

HTPC Specs: Show details

#9

Post by STC » Tue Apr 30, 2013 12:37 pm

I knew you'd do that! :D :D

"She canny tek it nooo longerrrrrr!"

I am being serious with the comment though.
All electronic 'clocks' have the crystal set in a tiny housing that oscillates to a set frequency and performs the supposedly accurate counting function for laptops and PC's (for instance) to keep the time. this is why the coin cell battery is required to power the counting mechanism when the main device is powered down.
By the Community, for the Community. 100% Commercial Free.

Want decent guide data back? Check out EPG123

User avatar
holidayboy

Posts: 2840
Joined: Sun Jun 05, 2011 1:44 pm
Location: Northants, UK

HTPC Specs: Show details

#10

Post by holidayboy » Tue Apr 30, 2013 12:56 pm

:thumbup:

Kind of like one of those magical jumping beans then ;)
Rob.

TGB.tv - the one stop shop for the more discerning Media Center user.

barnabas1969

Posts: 5738
Joined: Tue Jun 21, 2011 7:23 pm
Location: Titusville, Florida, USA

HTPC Specs: Show details

#11

Post by barnabas1969 » Tue Apr 30, 2013 2:46 pm

The frequency at which a crystal oscillates varies with temperature. As you can imagine, it's impossible to make a PC's clock 100% accurate because the oscillator is located inside the case. It heats up gradually when you turn on the PC, then cools down when you turn it off. If the crystal oscillator was located outside the case, it would be easier to make it accurate.

User avatar
mcewinter

Posts: 999
Joined: Thu Jun 30, 2011 8:33 pm
Location: Chicago

HTPC Specs: Show details

#12

Post by mcewinter » Tue Apr 30, 2013 3:09 pm

foxwood wrote:
mcewinter wrote:I don't think servers are the problem. Windows tends to refuse to sync the time. I use the method JazJon posted and it's quite reliable.
Time.windows.com often fails to respond - I'm pretty sure it's a server problem, not a Windows issue, because I don't see those failures using other servers.
From what I understand, the real issue is the frequency in which Windows actually updates the time. I've never really had issues reaching out to time servers, at least not permanantly.

http://www.pretentiousname.com/timesync/index.html

foxwood

Posts: 1761
Joined: Fri Sep 07, 2012 3:43 pm
Location:

HTPC Specs: Show details

#13

Post by foxwood » Tue Apr 30, 2013 3:49 pm

mcewinter wrote:From what I understand, the real issue is the frequency in which Windows actually updates the time. I've never really had issues reaching out to time servers, at least not permanantly.
When I'm asked to check out a PC or laptop for a friend, I'll usually check the time sync as I go through and update various things. I frequently see an error when I try to force a sync against time.windows.com, which is what they all default to. I'd never have even bothered looking for an alternative time source if that error wasn't so frequent.

I don't see that error when I check those machines again, after I've changed the Time server that they use. That leads me to believe that it's a problem with the time.windows.com servers, not with Windows itself.

User avatar
mcewinter

Posts: 999
Joined: Thu Jun 30, 2011 8:33 pm
Location: Chicago

HTPC Specs: Show details

#14

Post by mcewinter » Tue Apr 30, 2013 4:20 pm

Nevertheless, the method mentioned above is what fixed my syncing issues. The obvious switching of servers had no effect.

barnabas1969

Posts: 5738
Joined: Tue Jun 21, 2011 7:23 pm
Location: Titusville, Florida, USA

HTPC Specs: Show details

#15

Post by barnabas1969 » Tue Apr 30, 2013 6:30 pm

mcewinter wrote:Nevertheless, the method mentioned above is what fixed my syncing issues. The obvious switching of servers had no effect.
It fixed mine too. Richard1980 posted about it more than a year ago. I set my scheduled task to trigger when the PC resumes from standby instead of hourly. Either way should would fine. The PC wakes 5 minutes before a recording is scheduled to begin, so it sync's the time right before starting a recording, and also whenever I wake it to watch TV.

User avatar
JazJon

Posts: 397
Joined: Wed Jun 15, 2011 5:42 pm
Location: San Francisco

HTPC Specs: Show details

#16

Post by JazJon » Thu May 02, 2013 5:30 am

Someone should write an app to make setup a breeze. Years ago the app Tardis used to be great. Looks like it hasn't been updated in many years though. I didn't search very hard but I'm sure some time sync app has to be out there that's x64 Win 8 compatible. (anyone?) I'm happy enough with the manual setup working, but I know I'll be annoyed with it's time to re-install windows at some point.

barnabas1969

Posts: 5738
Joined: Tue Jun 21, 2011 7:23 pm
Location: Titusville, Florida, USA

HTPC Specs: Show details

#17

Post by barnabas1969 » Thu May 02, 2013 2:00 pm

JazJon wrote:Someone should write an app to make setup a breeze. Years ago the app Tardis used to be great. Looks like it hasn't been updated in many years though. I didn't search very hard but I'm sure some time sync app has to be out there that's x64 Win 8 compatible. (anyone?) I'm happy enough with the manual setup working, but I know I'll be annoyed with it's time to re-install windows at some point.
You can just export your scheduled task to an XML file. Zip it, and attach it to your first post in this thread. Then others can simply unzip it and import it into their task scheduler.

User avatar
JazJon

Posts: 397
Joined: Wed Jun 15, 2011 5:42 pm
Location: San Francisco

HTPC Specs: Show details

#18

Post by JazJon » Tue May 07, 2013 4:16 am

foxwood wrote:You can also use the time servers that people vounteer through ntp.org.

The following command sets the Windows Time Service up to synchronize against a group of NTP servers, and ntp.org uses round robin DNS to share those requests out among over 700 NTP servers in the US. If you are based somewhere else in the world, you should replace .us with your own country code, so that you use an NTP server that's closer to you, and therefore should give a faster response.

w32tm /config /syncfromflags:manual /manualpeerlist:0.us.pool.ntp.org,1.us.pool.ntp.org,2.us.pool.ntp.org,3.us.pool.ntp.org


See http://www.ntp.org for more information.
Well I noticed my recordings were 4 minutes off today. I'm guessing my IP got black listed for hourly updates or the time server I waas using is just down today. I was using time-b.nist.gov

Right click clock lower right, pick: Adjust Date/Time, pick: Internet Time (tab), click: Change settings (button)
So again, The server I had luck with for while was time-b.nist.org I tried a manual update and it timed out which explains why the scheduled task failed as well. I suspect my IP got black listed for hourly updates or they are down today. I changed to time-a.nist.gov and it's good again. I'd rather not have to mess with this every week so I'd like to use the time pool suggestion above.

I opened a command prompt above from an admin elevated command prompt. I ran: w32tm /config /syncfromflags:manual /manualpeerlist:0.us.pool.ntp.org,1.us.pool.ntp.org,2.us.pool.ntp.org,3.us.pool.ntp.org
It said The command completed successfully.

Are we supposed to see anything in the "Synchronize with an Internet time server" drop down menu that reflects these changes? I don't see anything new, maybe I need to reboot? (I'll edit my post if it shows up) Maybe it's never shown to us? (please clarify)

barnabas1969 wrote:
JazJon wrote:Someone should write an app to make setup a breeze. Years ago the app Tardis used to be great. Looks like it hasn't been updated in many years though. I didn't search very hard but I'm sure some time sync app has to be out there that's x64 Win 8 compatible. (anyone?) I'm happy enough with the manual setup working, but I know I'll be annoyed with it's time to re-install windows at some point.
You can just export your scheduled task to an XML file. Zip it, and attach it to your first post in this thread. Then others can simply unzip it and import it into their task scheduler.

Will do after I sort out the above

foxwood

Posts: 1761
Joined: Fri Sep 07, 2012 3:43 pm
Location:

HTPC Specs: Show details

#19

Post by foxwood » Tue May 07, 2013 4:48 am

I'd suggest that if your hardware is so flakey that you need to "fix" the time on an hourly basis, you should be looking for other problems!

You might want to see if you can get an NTP daemon running on a dd-wrt router, that hopefully will be more accurate than your PC, and can get by on daily updates, while your PC queries it on a hourly basis, though I really doubt that nist. gov are blacklisting you on the basis of 24 hits a day - the overhead of blacklisting you would be greater than the cost of responding to your queries.

As for whether you should see the list from the W32tm command in the GUI, probably not - it's a list of servers, and the GUI doesn't do lists. But I don't know off the top of my head the relationship between the different settings - you might want to see what's recorded in the eventvwr when time-syncing is going on.

User avatar
JazJon

Posts: 397
Joined: Wed Jun 15, 2011 5:42 pm
Location: San Francisco

HTPC Specs: Show details

#20

Post by JazJon » Tue May 07, 2013 5:02 am

foxwood wrote:I'd suggest that if your hardware is so flakey that you need to "fix" the time on an hourly basis, you should be looking for other problems!

You might want to see if you can get an NTP daemon running on a dd-wrt router, that hopefully will be more accurate than your PC, and can get by on daily updates, while your PC queries it on a hourly basis, though I really doubt that nist. gov are blacklisting you on the basis of 24 hits a day - the overhead of blacklisting you would be greater than the cost of responding to your queries.

As for whether you should see the list from the W32tm command in the GUI, probably not - it's a list of servers, and the GUI doesn't do lists. But I don't know off the top of my head the relationship between the different settings - you might want to see what's recorded in the eventvwr when time-syncing is going on.
I'm not sure what to do hardware-wise. I'm using a new Apple MAC Mini i7. I've already swapped the hard drive for SSD so it's not possible to use warranty to swap it out very easy at this point. :-( Worst case if another mini-PC i7 becomes available that is as good or better than the MAC Mini I'll buy that and sell the Mac Mini. (maybe something with HD 5000 graphics, an upgrade from my current HD 4000)

I happen to have DD-WRT firmware on my Linksys router. Where can I find info on how to setup NTP daemon on it? Can I force windows to sync time against that every 10 minutes than instead? I'm assuming I'd use the gateway IP or something then, and some registry hack to get windows time sync to use it. (guessing)

I'll poke around the eventvwr

Post Reply