LaunchDaemons给出错误127

问题描述 投票:-1回答:1

我运行LaunchDaemons时遇到问题这是我的.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>com.startup</string>
<key>ProgramArguments</key>
<array>
    <string>/Users/myuser/project/workspace/tomcat/run/tomcat-
   exp.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WatchPaths</key>
<array>
   <string>/Users/myuser/project/workspace/tomcat/log/exp.out</string>
</array>
</dict>
</plist>

这是我得到的错误,我一直试图解决这个问题几个小时,但没有suceess :(

当我检查系统日志时,这是我发现的:

16239 Dec 28 21:36:29 myyser MRT[1481]: Error: SMJobRemove: The 
operation couldn’t be completed. (CFErrorDomainLaunchd error 2.)
16240 Dec 28 21:36:29 myuser com.apple.xpc.launchd[1] 
(com.apple.mrt[1481]): Service exited with abnormal code: 2
16241 Dec 28 21:36:29 myuser com.apple.xpc.launchd[1] (com.apple.mrt): 
Service only ran for 0 seconds. Pushing respawn out by 10 seco      
nds.
ios daemon launchd start-stop-daemon
1个回答
0
投票

你的plist看起来正在运行shell脚本。未找到命令时报告退出代码127,通常$ PATH不正确或仅仅是拼写错误。

除此之外,你的plist看起来还不错,虽然我只使用了OnDemand,但我还没有运行脚本。我通常用来调试守护进程的是从命令行运行它们

# /bin/launchctl load /Library/LaunchDaemons/mydaemon.plist

并在shell上查看fprintf的调试消息。您可以通过添加重定向您的标准输出

<key>StandardOutPath</key>
<string>/var/log/mylog.log</string>

到你的.plist。当您通过命令行手动启动时,您的守护程序是否可以正常工作?

有关bash脚本的退出代码,请参阅this link

© www.soinside.com 2019 - 2024. All rights reserved.