launchd doesn't launch my daemon

Kimi Wu picture Kimi Wu · May 29, 2013 · Viewed 22.5k times · Source

I'm trying to figuring out why my daemon doesn't be launched automatically (on Mac 10.8.3). However, it works well on other machines. Here is my plist under /Library/LaunchDaemons/

<?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>

I didn't see any error messages in /var/log/system.log. I have checked the permission and owner of my daemon. If i put my plist under /System/Library/LaunchDaemons/, it can be launched after reboot. But it's not a good solution for me. If i use "launchctl load /Library/LaunchDaemons/com.MyApp.tmsm.launcher", it works well. If i install other commercial software which is a daemon and have a plist under /Library/LaunchDaemons/, it can't be launched, too.

It seems any plist under /Library/LaunchDaemons/ isn't loaded by system. I also try to turn on launchctl debug level with the command, "launchctl log level debug", but there is no more messages after reboot. Is the debug level reset after reboot? Is other logs or configs i can check??

Thanks.

Answer

cody picture cody · May 29, 2013

Try to load it with -w parameter: sudo launchctl load -w /Library/LaunchDaemons/blablabla.plist. Looks like problem in Disabled key. see man launchctl for details.

If that will not work I suggest you to enable some logging to file in your daemon to see if it starts (may be it just exits immediately?)