如何调试无法在启动时运行的启动脚本? [英] How can I debug a Launchd script that doesn't run on startup?
问题描述
我有一些自制软件的启动脚本.但是,当我重新启动计算机时,必须手动运行它们:
I have some Launchd scripts from homebrew. However I have to manually run them when I restart my computer:
launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.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>
<true/>
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>Program</key>
<string>/Users/dash/.local/Cellar/mysql/5.1.49/bin/mysqld_safe</string>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>dash</string>
<key>WorkingDirectory</key>
<string>/Users/dash/.local/var</string>
</dict>
</plist>
我认为这应该在启动时发生.我想念什么?
I thought this should happen on startup. What am I missing?
推荐答案
在您的plist中找到的最佳调试方式:
Best way I found to debug, in your plist:
<key>StandardErrorPath</key>
<string>/tmp/mycommand.err</string>
<key>StandardOutPath</key>
<string>/tmp/mycommand.out</string>
打开控制台应用程序,在所有消息"中,当您的应用程序失败或成功时,您应该会看到条目.像这样:
Open Console app, in "All Messages" you should see entries when your app fails or succeeds. Like this:
4/28/15 10:43:19.938 AM com.apple.xpc.launchd[1]: (mycommand[18704]) Service exited with abnormal code: 1
我在ProgramArguments中遇到的问题将命令的每一项都作为数组中的<string>
项.
The issue I had was with ProgramArguments takes each item of command as <string>
item in the array.
就我而言,为shell脚本生成一个简单的包装效果更好.
该脚本设置了基本的文件夹结构,以将外壳程序脚本制作为OS X应用程序"- https://gist .github.com/mathiasbynens/674099 .这对于您的mysql -u arg1
命令可能会更好.
In my case, generating a simple wrapper for shell script worked even better.
This script sets up basic folder structure to make a shell script into an OS X "app" - https://gist.github.com/mathiasbynens/674099. This might work better for your mysql -u arg1
command.
这篇关于如何调试无法在启动时运行的启动脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!