Launchd 不工作

Launchd is not working

我在制作 Launchd 脚本时遇到问题。这相当简单,它需要做的就是启动一个应用程序——位置是:/Library/Desktop Pictures/wallpaper

我已经使用终端加载了文件,终端没有给出任何错误,但脚本没有执行。我需要脚本每 1 小时执行一次。

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>RunAtLoad</key>  
        <true/>
        <key>KeepAlive</key>
        <true/>
        <key>Label</key>
        <string>wallpaper.restart</string>
        <key>ProgramArguments</key>
        <array>
                <string>/Library/Desktop Pictures/wallpaper.wallpaperapp.app</string>
        </array>
        <key>StartCalendarInterval</key>
        <dict>
            <key>Hour</key>
            <integer>1</integer>

       </dict>
</dict>
</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>KeepAlive</key>
    <dict>
        <key>AfterInitialDemand</key>
        <true/>
    </dict>
    <key>Label</key>
    <string>com.plisterine.backgroundchanger</string>
    <key>LowPriorityIO</key>
    <false/>
    <key>Nice</key>
    <integer>0</integer>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/osascript</string>
        <string>/Library/Desktop Pictures/wallpaper/wallpaper.scpt</string>
    </array>
    <key>StartInterval</key>
     <integer>3600</integer>

</dict>
</plist>

StartCalendarInterval 运行 每天在特定时间发送脚本,在您的情况下是 01:00(凌晨 1 点)

要运行它每个小时都要写

<key>StartInterval</key>
<integer>3600</integer>