Macos – How to load system-wide daemon on Mac OS X

launchdmacmacosunix

I'm trying to load my daemon-app with this command

launchctl load /Library/LaunchDaemons/myPlistFileName

It works fine, but only while my user is logged in on system.

How can I load my deamon-app, which will stay loaded without any user logged into the system (like the windows-services)??

The command

sudo launchctl load /Library/LaunchDaemons/myPlistFileName

give me an error -> nothing found to load

Which is the right way to do this?

Best Answer

In order to load the job for everyone you need to run launchctl under root privileges. If the job is already loaded under your user account, it won't load using root privileges instead.

Try running launchctl unload /Library/LaunchDaemons/myPlistFileName first before running sudo launchctl load -w /Library/LaunchDaemons/myPlistFileName. Take a look at the output in system.log (you can view it using Console.app if you'd prefer) that occurs when you load the daemon.

Related Question