我的.plist如下所示...在/var/log.system.log中,我可以看到
(com.example.exampled[24728]): posix_spawn("/usr/local/bin/ruby /Users/radek/Sites/sinatrasvn/web.rb", ...): No such file or directory
(com.example.exampled[24728]): Exited with exit code: 1
(com.example.exampled): Throttling respawn: Will start in 10 seconds
但是如果我运行/usr/local/bin/ruby /Users/radek/Sites/sinatrasvn/web.rb
脚本,效果很好。任何的想法?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.exampled</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/ruby /Users/radek/Sites/sinatrasvn/web.rb</string>
</array>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
launchd
不使用外壳程序来运行程序;它使用exec
系统调用。这就是为什么上面的plist使用数组的原因。
您正在将该数组的单个元素设置为包含空格的字符串,这将导致launchd
尝试执行exec("/usr/local/bin/ruby /Users/radek/Sites/sinatrasvn/web.rb")
-当然,这不是文件名。相反,您想设置数组:
<array>
<string>/usr/local/bin/ruby</string>
<string>/Users/radek/Sites/sinatrasvn/web.rb</string>
</array>
这会将路径作为单独的参数传递给exec()
,然后正确的事情就会发生。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句