这是我第一次尝试创建守护进程,所以如果我说一些菜鸟的话,请耐心等待。
我使用 AppleScript 编写了一个测试脚本。最终,这将更加强大,并成为会议播音员和其他一些通知,以开始我的一天。这是现在的脚本:
say "Hello Steve, the job has launched!"
这是列表:
我将它保存在 /Library/LaunchDaemons 作为 local.jeeves.plist。我通过目视找到它并运行来确认它在那里:
launchctl list
跑步
launchctl list | grep local.Jeeves
也证实了它的存在。
我确认该Program
键引用的脚本在该目录中。它还可以运行,因为我可以从 AppleScript 运行它
回到 plist。我通过运行加载它:
launchctl load /Library/LaunchDaemons/local.jeeves.plist
终端没有产生任何错误。
如果我运行:
launchctl start local.jeeves
或者
launchctl start local.Jeeves
没有结果。没有错误,但脚本没有运行。
所以我对我的 system.log 做了一些挖掘,发现了这些错误:
Aug 28 15:26:17 Steves-MBP com.apple.xpc.launchd[1] (com.apple.xpc.launchd.user.domain.501.100009.Aqua): Could not read path: path = /Users/xxxxxxx/Library/LaunchDaemons/local.jeeves.plist, error = 2: No such file or directory
Aug 28 15:27:33 Steves-MBP com.apple.xpc.launchd[1] (com.apple.xpc.launchd.user.domain.501.100009.Aqua): Could not read path: path = /Users/xxxxxxxx/Library/LaunchDaemons/local.jeeves.plist, error = 2: No such file or directory
Aug 28 15:28:05 Steves-MBP com.apple.xpc.launchd[1] (local.Jeeves[14803]): Could not find and/or execute program specified by service: 13: Permission denied: /Users/xxxxxxx/Scripts/AppleScripts/testScript.scpt
Aug 28 15:28:05 Steves-MBP com.apple.xpc.launchd[1] (local.Jeeves[14803]): Service setup event to handle failure and will not launch until it fires.
Aug 28 15:28:05 Steves-MBP com.apple.xpc.launchd[1] (local.Jeeves[14803]): Service exited with abnormal code: 78
所以现在我知道了这个问题,或者是那种。这是目录问题的权限还是根本找不到目录?