LaunchAgent 打开 FileMaker 脚本

发布于 2024-12-28 23:29:51 字数 1666 浏览 2 评论 0原文

我在 OS X 10.4.11 上使用 launchd 对 FileMaker 脚本进行类似 cron 的调度时遇到了麻烦。 (我在 serverfault 中描述了我早期的痛苦。)起初我认为问题在于 FileMaker 脚本打开了一个 GUI,这对于 LaunchDaemon 来说似乎是禁止的。然后我把它改为LaunchAgent,允许使用窗口资源,但仍然不行。

以下是一些没有意义的事情的列表:

  1. 如果您在手动加载任务后使用 launchctl 启动任务,那么一切都会正常工作。

    sudo launchctl start my.script.name

  2. 如果您选择未来几分钟的 StartInterval(而不是未来几个小时),然后加载 .plist,则一切正常。 (我一开始以为这可能与屏幕保护程序有某种关系——当 ss 执行时,某些东西会被垃圾收集或其他东西;但如果它甚至在 ss 启动后就被安排,只要它不是这样,它似乎就可以工作太远了。)

  3. 我将 FileMaker 程序的调用封装在 shell 脚本中,该脚本除了执行 FileMaker 程序之外,还将时间戳写入日志文件。通过阅读此日志文件,我可以验证,是的,launchd 确实在适当的时间调用了 shell 脚本。或者至少,几乎是因为:

  4. 日志显示了一些奇怪的东西:如果我安排脚本在晚上 8:08 启动,我会得到两次执行,彼此相隔几秒钟:

    <块引用>

    [2012 年 1 月 24 日星期二 20:07:57 CST] 正在执行脚本!

    [2012 年 1 月 24 日星期二 20:08:00 CST] 正在执行脚本!

    日志

我已经束手无策了——我已经阅读了相关的手册页、Apple 技术文档以及 StackExchange 网站上的其他文章。我真的已经尽力做功课了。任何能帮助我的人都会有一些严重的业力。

再说一遍,这里的 .plist 删除了一些繁琐的内容(XML 定义、日志信息)。 (请记住,这在手动加载时有效,所以我知道 plist 本身没问题。)

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

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

影子的影子 2025-01-04 23:29:51

您必须为此使用 launchd 吗?

我使用内置的 Cron 工具(通过 CronniX GUI 打开本地 FileMaker 文件,然后运行FileMaker 服务器上的脚本。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文