How do I use non-"legacy" launchctl commands to load and unload plists?

Solution 1:

I asked the Twitter user @launchderp:

@launchderp Arelaunchctl load and unload still safe to use, at least until 10.12 or whatever comes next?

c.f How do I use non-"legacy" launchctl commands to load and unload plists?

And @launchderp replied

@tjluoma Yeah they're still safe. Too many years of dependencies to break them.

While this may not seem like an official Apple statement, I believe this person to be someone who is actively working on launchd for Apple, and trust what they say. YMMV.

Moral of the story: If load/unload is working for you, keep using them :-)

Solution 2:

The article referred by TJ Luoma is very helpful. Steps for Launch Daemon:

  1. Save your plist file in /Library/LaunchDaemons/ as usual. Let's say the file is com.example.mysrv.plist, and the Label in plist is com.example.mysrv.
  2. sudo launchctl bootstrap system /Library/LaunchDaemons/com.example.mysrv.plist. Note that the path can be relative (to $PWD) or absolute.
  3. Check the service with sudo launchctl print system/com.example.mysrv. It should say "running".

Launch Agents should be similar. Caveat: I have no idea how to stop a service without unloading it through bootout.