发布plist在启动时启动,但不应该

时间:2012-11-05 18:55:22

标签: plist launchd

就像在锡上所说的那样,我有一个发射脚本应该在凌晨1点20分发射,但似乎是在用户登录后不久发射的。谁能看到我做错了什么?

我编写ProgramArguments的方式是什么,到应用程序的容器内启动它?我没有成功地以任何其他方式启动(applescript)应用程序,即open ~/Library/CDesResources/Shutdown.app似乎不起作用。

plist保存在~/Library/LaunchAgents/shutdownAgent.plist中,因此只有在该用户登录正确时才会触发?

非常感谢您的新鲜眼光和专业知识。

<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key>
        <string>shutdownAget</string>
        <key>Nice</key>
        <integer>-20</integer>
        <key>ProgramArguments</key>
        <array>
            <string>/Library/CDesResources/Shutdown.app/Contents/MacOS/applet</string>
        </array>
        <key>RunAtLoad</key>
        <false/>
        <key>ServiceDescription</key>
        <string>launch the shutdown script</string>
        <key>StartCalendarInterval</key>
        <dict>
            <key>Hour</key>
            <integer>1</integer>
            <key>Minute</key>
            <integer>20</integer>
        </dict>
    </dict>
    </plist>

1 个答案:

答案 0 :(得分:1)

来自launchd.plist(5)的手册页:

  

与计算机处于睡眠状态时跳过作业调用的cron不同,launchd将在下次计算机唤醒时启动作业。如果多个        在计算机被唤醒之前发生间隔,这些事件将在从睡眠中唤醒时合并为一个事件。

所以launchd在启动时正确注意到该作业未在01:20运行并为您安排。