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.

2
  • 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 Commented May 30, 2013 at 5:20
  • the permission and owner of the definition file is correct. -rw-r--r-- 1 root wheel Commented May 30, 2013 at 9:05

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

2 Comments

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.
Before your daemon will start automatically at system start, you need to load it first with -w parameter.
-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...

3 Comments

/Library/LaunchDaemons permissions on my system are 755 and it works fine. I haven't changed it myself so I assume its the default.
On 10.11, they appear to be 644 by default.
Directories must have the x bit so 644 makes no sense

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.