1

I'm having a hell of a time getting cron-like scheduling of a FileMaker script using launchd on OS X 10.4.11. (I described my early travails over at serverfault.) At first I thought the problem was that the FileMaker script opens a GUI, which seems to be verboten for a LaunchDaemon. Then I made it a LaunchAgent instead, which is allowed to use windowing resources, and still no go.

Here's a list of the things that make no sense:

  1. If you use launchctl to start the task after you've loaded it by hand, then everything works fine.

    sudo launchctl start my.script.name

  2. If you select a StartInterval that is a few minutes in the future (as opposed to several hours in the future) and then load the .plist, everything works. (I thought at first this might have been related to the screensaver somehow -- that when the ss executes, something gets garbage-collected or something; but it seems to work if it's scheduled even after the ss has started, so long as it's not too far in the future.)

  3. I wrapped the invocation of the FileMaker program inside a shell script which, in addition to executing the FileMaker program, also wrote a timestamp to a log file. From reading this log file I can verify that, yes, the shell script was indeed invoked by launchd at the appropriate time. Or at least, almost, because:

  4. The log shows something strange: if I schedule the script to be launched at 8:08pm, I get two executions, a few seconds apart from each other:

    [Tue Jan 24 20:07:57 CST 2012] Executing script!

    [Tue Jan 24 20:08:00 CST 2012] Executing script!

I'm kind of at the end of my rope here -- I've read the relevant manpages, Apple technical docs, other articles on the StackExchange sites. I've really done my homework as far as I'm able. Anyone who could help me out would have some serious karma headed their way.

For the hell of it, again, here's the .plist with some cruft (XML definition, logging info) edited out. (Remember, this works when loaded manually, so I know the plist itself is okay.)

<plist version="1.0">
<dict>
    <key>Label</key>
    <string>shane.useragent.launcher</string>
    <key>ProgramArguments</key>
    <array>
            <string>/Users/shane/launchFM.sh</string>
    </array>
    <key>StartCalendarInterval</key>
    <dict>
            <key>Hour</key>
            <integer>20</integer>
            <key>Minute</key>
            <integer>8</integer>
    </dict>
</dict>
</plist>
Community
  • 1
  • 1
shanusmagnus
  • 2,340
  • 2
  • 20
  • 19
  • A couple of thoughts: 1: Could FileMaker be busy doing something else when you the script and therefore not responding? 2: Is the database you want to script still open and, if it is, is it still the active database in FileMaker? 3: Have you tried automating with iCal alerts, instead? 4: What is your FileMaker setup? FM Pro/Advanced? FM Server? Shared file? Single user file? – pft221 Jan 25 '12 at 16:29
  • Thanks for the response. #1: No; with the possible exception that the multiple starts is causing it to interrupt itself and therefore screw things up. I'll think about that. #2: running the script makes the appropriate database active. #3: I haven't, but it may come to that. I wanted to do things the Apple-blessed way, but am rapidly losing patience with that. #4: FM Pro. As to the rest, I'm not sure. Would you expect different behaviors in these various cases, in a situation where nobody else is running any FM based stuff? – shanusmagnus Jan 25 '12 at 23:30
  • #4: If nobody else is running FM then not generally. – pft221 Jan 26 '12 at 14:42

1 Answers1

0

Do you have to use launchd for this?

I use built in Cron facility (via the CronniX GUI to open a local FileMaker file which then runs a script on our FileMaker server.

Adam Dempsey
  • 2,913
  • 5
  • 24
  • 26