launchctl unload say: Could not find specified service

4

I'm trying to make a plist file in order to start nginx on boot. When starting nginx with launchctl it starts the service. But it cannot unload it, and print "Could not find specified service".

$ ps aux | grep nginx
me (...) grep nginx

$ sudo launchctl load /System/Library/LaunchDaemons/nginx.plist 
(no output)

$ ps aux | grep nginx
me (...) grep nginx
nobody (...) nginx: worker process
root (...) nginx: master process /opt/nginx/sbin/nginx

$ sudo launchctl unload /System/Library/LaunchDaemons/nginx.plist 
/System/Library/LaunchDaemons/nginx.plist: Could not find specified service

This is the content of /System/Library/LaunchDaemons/nginx.plist

$ cat /System/Library/LaunchDaemons/nginx.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
                       "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key><string>nginx</string>
    <key>Program</key><string>/opt/nginx/sbin/nginx</string>
    <key>KeepAlive</key><true/>
    <key>NetworkState</key><true/>
    <key>StandardErrorPath</key><string>/opt/nginx/logs/system.log</string>
    <key>LaunchOnlyOnce</key><true/>
  </dict>
</plist>

Any help appreciated. Cheers

Benj

Posted 2018-10-08T09:17:44.573

Reputation: 141

Any luck with this? I'm facing it at the moment and can't figure that out either – rpbaltazar – 2020-02-04T02:15:45.117

Answers

0

Try removing the sudo and just run:

launchctl unload /System/Library/LaunchDaemons/nginx.plist

When attempting to unload some LaunchDaemons, it will return "Could not find specified service" if using sudo.

Employee

Posted 2018-10-08T09:17:44.573

Reputation: 153