4

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.

Kimi Wu
  • 309
  • 1
  • 4
  • 17
  • Please have a look at the job definition file. launchd(8) will refuse to load job if: - the job definition file is writable by `group` or `other` - the job definition is not owned by `root` (or the user specified in the job definition) - the job definition file name does not end with `.plist` – LCC May 30 '13 at 05:20
  • the permission and owner of the definition file is correct. `-rw-r--r-- 1 root wheel` – Kimi Wu May 30 '13 at 09:05

2 Answers2

4

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

cody
  • 3,233
  • 1
  • 22
  • 25
  • Load my daemon with/without -w parameter manually is fine. My daemon can't be loaded automatically while system starts. My daemon does have logs at the beginning and it doesn't show. I also used `launchctl list` to check my daemon has been loaded or not and i couldn't see my daemon on the list. I checked the Disabled key in `/var/db/launchd.db/com.apple.launchd/overrides.plist` but i can't see my daemon on this plist. – Kimi Wu May 30 '13 at 09:28
  • Before your daemon will start automatically at system start, you need to load it first with -w parameter. – cody May 30 '13 at 09:31
-1

I found the root cause...It's quite stupid... The permission of my plist under /Library/LaunchDaemons/ is correct. However, the permission of /Library/LaunchDaemons/ is modified to 755. That's why any daemons registered under /Library/LaunchDaemons/ can't be loaded automatically...

Kimi Wu
  • 309
  • 1
  • 4
  • 17