MacOS – How to use non-“legacy” launchctl commands to load and unload plists

command linedevelopmentlaunchdmacosstartup

I have some plist files in ~/Library/LaunchAgents.

I have been happily using launchctl load -w and launchctl unload -w to turn these on and off for years. However, I notice that now load and unload are relegated to the "legacy" section of the man page. Let's call one of them com.example.service.plist.

However, when I try to interact with these plists via launchctl enable "gui/$(id -u)/com.example.service" and launchctl disable "gui/$(id -u)/com.example.service", other launchd commands seem to report success – for example, launchctl print "gui/$(id -u)" totally shows me disabled flags that correspond to the state that I've set – the services don't actually start and stop or listen and unlisten on their ports.

Is there some step I'm missing? For the moment I am sticking with load and unload but I'd like to learn the non-deprecated way of interacting with this stuff before Apple eventually slams the door on the old/bad way…

Best Answer

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