How do I use non-"legacy" launchctl commands to load and unload plists?
Solution 1:
I asked the Twitter user @launchderp:
@launchderp Are
launchctl 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:
- Save your plist file in
/Library/LaunchDaemons/
as usual. Let's say the file iscom.example.mysrv.plist
, and the Label in plist iscom.example.mysrv
. -
sudo launchctl bootstrap system /Library/LaunchDaemons/com.example.mysrv.plist
. Note that the path can be relative (to$PWD
) or absolute. - 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
.