Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to force an NTP update from FileMaker?

Featured Replies

I manage a fleet of workstations that are all configured to sync time with the NTP server 0.pool.ntp.org.  While there are some Windows workstations in the mix, there are many Macs running OS X Mavericks 10.9.1, and for now I'd like to just focus on the Macs, since that's what my most vocal users are using.

 

Even though I have everything set correctly in System Preferences, (i.e. the 'Set date and time automatically:' checkbox is set, etc.), the computers tend to drift over time.  My own workstation was off by 2 minutes and 1 second today, for instance.  I checked Activity Monitor and 'ntpd' was running with no apparent problems.  BUT, the only way my time would update is if I take a trip to System Preferences > Date & Time.  The moment I enter the Date & Time pref pane, the time updates.  I suspect if I were to restart, it would also work, but I haven't tried that.  We tend to just leave our computers on.

 

I suspect this is a bug with OS X, but I'd like to take the matter into my own hands.  Here's my scripting so far:

 

#Check local time vs. server time

Set Variable [ $time_difference; Value:Get(CurrentHostTimeStamp) - Get(CurrentTimeStamp) ]

If [ Abs($time_difference) > Time(0; 1; 0) ]

    #Time difference is greater than 1 minute

   If [ $$current_workstation_platform = "Mac" ]
      #Attempt to update system clock via shell script

      Perform AppleScript [ Calculated AppleScript: "do shell script "ntpd -g"" ]

      Set Variable [ $time_difference_old; Value:$time_difference ]

      Set Variable [ $time_difference; Value:Get(CurrentHostTimeStamp) - Get(CurrentTimeStamp) ]

      If [ Abs($time_difference) ≤ Time(0; 0; 1) ]

         #Time is now within 1 second and is considered fixed

         //  A notification is sent to me regarding the problem and the fix.

      End If

   End If

End If

If [ WS—workstations::i_TimeDifferenceLocalVsServer ≠ $time_difference ]

   #Time difference is different than recorded on workstation record - Update value

   Set Field [ WS—workstations::i_TimeDifferenceLocalVsServer; $time_difference ]

   If [ Abs(WS—workstations::i_TimeDifferenceLocalVsServer) > Time(0; 1; 0) ]

      #Time difference is greater than 1 minute - Notify admin

      //  A notification is sent to me regarding the problem.

   End If

End If

 

The shell script "ntpd -g" apparently requires sudo access, and the point of this is to silently fix the computer's clock, so it is not reasonable to require this for my unauthorized users.

 

How have others dealt with this issue?

I have not dealt with this issue but I'm surprised to hear that the clocks drift so much over time. I wonder if you could run ntpd in crontab every night? I think cron runs with admin privileges. You would need admin access to users workstations to set it up and it would take FileMaker out of the loop. (Crontab has been deprecated on Mac OS X in favor of launchd, but it still works fine and is much easier to setup.)

  • Author

I might just do that.  Thanks for the suggestion.  Being the "IT Guy" I certainly have admin access to all the machines.

  • 5 weeks later...

First: this is a known bug. The short story is that Apple changed how they handled time syncing in 10.9 to conserve power: https://discussions.apple.com/message/23924875#23924875

 

Second: If you have access to each of the local machines you can modify the sudoers file so that it doesn't prompt you when entering a password.

In terminal on the local machine:

type "sudo pico /etc/sudoers"

type in the user password

Under the heading "# User privilege specification" add the following line right before the break: "%users ALL=(ALL) NOPASSWD: /usr/loca/sbin/ntpd"

Finally, modify your FM script so that the AppleScript is executing "do shell script "sudo ntpd -g""

 

The change to the sudoers file will now allow any user to execute ntpd as root without having to type in the password.

 

Depending on how your environment is setup, it would be MUCH BETTER to substitute "%users" with the username of the user on that specific computer. But, if the environment is a shared environment and you can't guarantee that a specific user will only be using a specific computer.

Well, I learned something today!

Well, I learned something today!

Glad to be able to help!

This is good to know. I've noticed my three machines, two on Mavericks and one on Lion, drifting from each other lately in terms of time. Actually even the two on Mavericks, one of which is used as an FMS, is different from my laptop which also runs Mavericks. Messy.

  • 1 year later...

OK, dead topic, but I'm grateful to @HazMatt for the idea of such a script, and Merlyn. Been facing ongoing same problems and it's dead handy. Another Applescript alternative if you don't mind the administrator password being in plain text in FileMaker: 

do shell script "sudo ntpd -g -q" user name "Administrator User Name" password "------" with administrator privileges

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.