launchd自动启动

时间:2014-11-30 10:36:58

标签: macos launchd launchdagent

尝试创建一个每天凌晨4点开始的任务,以重新启动我的mac并执行一些维护脚本。这是我的剧本:

<?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>local.job</string>
    <key>ProgramArguments</key>
    <array>
            <string>/usr/bin/osascript</string>
            <string>/Users/Media/Scripts/RestartMac.scpt</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>StandardErrorPath</key>
    <string>/Users/Media/Scripts/Output/RestartMac.txt</string>
    <key>StandardOutPath</key>
    <string>/Users/Media/Scripts/Output/RestartMac.txt</string>
    <key>StartCalendarInterval</key>
    <array>
            <dict>
                    <key>Hour</key>
                    <integer>04</integer>
                    <key>Minute</key>
                    <integer>00</integer>
            </dict>
    </array>
</dict>
</plist>

如果我运行launchctl unload / load来重新加载我的plist文件,它将执行脚本。我有点困惑,因为我已将RunAtLoad参数设置为false。尝试了很多东西,但我无法让它运行。有谁知道我的错是什么?

操作系统:OS X 10.9

1 个答案:

答案 0 :(得分:-1)

你试过吗

<key>AbandonProcessGroup</key>
<true/>