[launchd-dev] Yosemite not starting a system launch agent

Damien Sorresso dsorresso at apple.com
Thu Jun 25 08:53:06 PDT 2015


James,

Your plist probably has the LimitLoadToSessionType key set to Background, which will prevent it from loading outside of a user's background session. So when you do a regular `launchctl load` from a Terminal window (for example), you're targeting the Aqua session, and launchd says no. Similarly, if you try and load it into the system session (either by running launchctl(1) under sudo(1) or by using the bootstrap subcommand with a "system" target), launchd will also say no.

If you remove the LimitLoadToSession type key, you'll be able to load the job wherever you'd like.
-damien

On 22 Jun, 2015, at 18:31, James Bucanek <subscriber at gloaming.com> wrote:
> Greetings,
> 
> Here's my problem in a nutshell:
> 
> I have a simple scheduler daemon that runs in the background for logged in users. The problem is that it won't start when installed in Yosemite (seems to start in all previous versions of OS X that use launchd).
> 
> Here's what my program does:
> 
> 1) I install the com.qrecall.sheduler.plist in /Library/LaunchAgents/ (with the correct ownership and access privileges).
> 
> 2) launchctl load -S Background /Library/LaunchAgents/com.qrecall.scheduler.plist
> (successful)
> 
> 3) launchctl start com.qrecall.scheduler
> (exits with status 1)
> 
> And the scheduler process is NOT started. All attempts to get it started through launchctl have failed.
> 
> However, I know that it's installed because if you simply restart the system the scheduler deamon starts running like a champ.
> 
> Now ... I know what you're going to say: "Dude! You should be using the new launchctl commands introduced in 10.10!"
> 
> Tried that. I can't seem to get anywhere with it. Basically, I don't know what I'm doing. I've read the man page for the new launchctl about 20 times and I'm still not sure how I should be using it.
> 
> For per-user agents, it seems pretty obvious that you would bootstrap and address the service in the user/login/gui domain (i.e. launchctl enable user/501/com.qrecall.scheduler).
> 
> But I don't understand how to treat a system-wide user agent that should be installed in /Library/LaunchAgents. Through trial and error, I've discovered that I can address the current user's instance of the scheduler process for commands like "kill". So this command works:
> 
>    launchctl kill TERM user/501/com.qrecall.scheduler
> 
> It sends a TERM signal and the daemon restarts.
> 
> However, I can't find anyway to use the bootstrap command to install it, the enable command won't start it, and the kickstart command says there's no such service.
> 
> It would seem to make sense that a system-wide agent would have to be installed in the system domain, but this command:
> 
>    sudo launchctl bootstrap system /Library/LaunchAgents/com.qrecall.scheduler
> 
> results in the error "/Library/LaunchAgents/com.qrecall.scheduler.plist: Service cannot load in requested session"
> 
> Attempts to use any other domain in the command result in a syntax error, so I'm completely stumped as to how the service should be installed.
> 
> I've figured out the I can enable and disable the per-user instance, but it has no effect on the running process. In other words, disabling won't halt the service and enabling it won't start it.
> 
> And don't get me started on unbootstrap, which doesn't appear to be implemented.
> 
> So, at this point I have my feet planted firmly in mid-air...
> 
> James Bucanek
> 
> _______________________________________________
> launchd-dev mailing list
> launchd-dev at lists.macosforge.org
> https://lists.macosforge.org/mailman/listinfo/launchd-dev



More information about the launchd-dev mailing list