macos - launchd 不启动我的守护进程

标签 macos launchd daemons

我试图弄清楚为什么我的守护进程没有自动启动(在 Mac 10.8.3 上)。但是,它在其他机器上运行良好。这是我在/Library/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.MyApp.tmsm.launcher</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Library/Application Support/MyApp/tmsmLauncher</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <false/>
    <key>StartInterval</key>
    <integer>60</integer>
  </dict>
</plist>

我在 /var/log/system.log 中没有看到任何错误消息.我查了 permissionowner我的 daemon .如果我把我的 plist 放在 /System/Library/LaunchDaemons/ 下,可以在reboot之后启动.但这对我来说不是一个好的解决方案。如果我使用“launchctl load /Library/LaunchDaemons/com.MyApp.tmsm.launcher”,它运行良好。如果我安装了其他商业软件,它是一个守护进程并且在 /Library/LaunchDaemons/ 下有一个 plist ,它也无法启动。

/Library/LaunchDaemons/ 下似乎有任何 plist没有被系统加载。我还尝试使用命令“launchctl log level debug”打开 launchctl 调试级别,但重新启动后没有更多消息。重启后调试级别是否重置?我可以检查其他日志或配置吗?

谢谢。

最佳答案

尝试使用 -w 参数加载它:sudo launchctl load -w /Library/LaunchDaemons/blablabla.plist .看起来像禁用键中的问题。见 man launchctl详情。

如果这不起作用,我建议您在守护程序中启用一些日志记录以查看它是否启动(可能只是立即退出?)

关于macos - launchd 不启动我的守护进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16809861/

相关文章:

ios - Xcode:使用新产品名称更新项目产品组

java - Swing 不在 Mac 上绘图

swift - Swift 3 开发快照中的 POST 请求给出 "ambiguous reference to member ' dataTask(带有 :completionHandler:)'

iphone - 为越狱的 iOS 制作守护进程

linux - 将 bash 脚本作为守护进程运行

ruby - Rufus-Scheduler、DaemonKit 和陷阱

java - 如何右对齐 Java SWT Unified ToolBar (OS X) 中的搜索栏

macos - 什么是 CFErrorDomainLaunchd 错误 2?

macos - launchd ExitTimeOut 不起作用

c - 守护进程什么时候会占用CPU?