launchctl unload 说:找不到指定的服务

launchctl unload 说:找不到指定的服务

我正在尝试制作一个 plist 文件以便在启动时启动 nginx。启动 nginx 时launchctl它会启动该服务。但它无法卸载它,并打印“找不到指定的服务”。

$ 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

这是/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>

任何帮助都值得感激。干杯

答案1

尝试删除sudo并运行:

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

"Could not find specified service"当尝试卸载一些 LaunchDaemons 时,如果使用则会返回sudo

相关内容