LaunchAgent opening FileMaker script

412 views Asked by At

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>
1

There are 1 answers

0
Adam Dempsey On

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.