我正在尝试在 OS X Mountain Lion 10.8.3 中安排一个简单的任务
launchctl start nextstopsun.helloworld
命令不执行脚本并向控制台抛出消息
4/2/13 9:50:49.663 PM com.apple.launchd.peruser.501[139]: (nextstopsun.helloworld[46729]) Job failed to exec(3) for weird reason: 8
我的 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>nextstopsun.helloworld</string>
<key>Program</key>
<string>/Users/nextstopsun/Work/scripts/hw.sh</string>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>21</integer>
<key>Minute</key>
<integer>15</integer>
</dict>
<key>UserName</key>
<string>nextstopsun</string>
</dict>
</plist>
脚本也很简单
echo "Hello World!" > hw.log
launchctl 加载它没有错误。 从 shell 执行脚本时,它按预期工作。 注销并重新登录无济于事。 在谷歌中没有找到任何答案。 “奇怪的原因:8”到底是什么意思?
最佳答案
一些建议:
- 使您的脚本可执行 (
chmod +x <your_script>
) 或通过 bash 或 sh 将脚本作为参数传递来启动它 - 很可能:您的 shebang 行 (#!) 中有错误,launchd 无法识别。试试
#!/bin/sh
或#!/bin/bash
.请注意,它必须是脚本的第一行。 - 首先通过
launchctl load <your_plist>
加载您的工作.但我认为你已经这样做了,否则会有其他错误消息。
关于macos - 由于奇怪的原因,启 Action 业无法执行(3): 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15771236/