title: LaunchAgent opening FileMaker script
body: <p>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 <a href="https://serverfault.com/q/352260/107821">serverfault</a>.)  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.</p>
  
  <p>Here's a list of the things that make no sense:</p>
  
  <ol>
  <li><p>If you use launchctl to start the task after you've loaded it by hand, then everything works fine.  </p>
  
  <p><code>sudo launchctl start my.script.name</code></p></li>
  <li><p>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.)</p></li>
  <li><p>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:</p></li>
  <li><p>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:</p>
  
  <blockquote>
    <p>[Tue Jan 24 20:07:57 CST 2012] Executing script!</p>
    
    <p>[Tue Jan 24 20:08:00 CST 2012] Executing script!</p>
  </blockquote></li>
  </ol>
  
  <p>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.</p>
  
  <p>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.)</p>
  
  <pre><code>&lt;plist version="1.0"&gt;
  &lt;dict&gt;
      &lt;key&gt;Label&lt;/key&gt;
      &lt;string&gt;shane.useragent.launcher&lt;/string&gt;
      &lt;key&gt;ProgramArguments&lt;/key&gt;
      &lt;array&gt;
              &lt;string&gt;/Users/shane/launchFM.sh&lt;/string&gt;
      &lt;/array&gt;
      &lt;key&gt;StartCalendarInterval&lt;/key&gt;
      &lt;dict&gt;
              &lt;key&gt;Hour&lt;/key&gt;
              &lt;integer&gt;20&lt;/integer&gt;
              &lt;key&gt;Minute&lt;/key&gt;
              &lt;integer&gt;8&lt;/integer&gt;
      &lt;/dict&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>