如果我不想让恶魔加载 and/or 自动启动,启动文件应该如何设置?

How should be the launchd file be if I don't want the deamon to load and/or start automatically?

我正在为 MySQL 添加一个我不想自动启动的 launchd 文件。只是想知道我应该在文件中更改什么。

/Library/LaunchDaemons/com.mysql.mysql.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>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>com.mysql.mysqld</string>
    <key>ProgramArguments</key>
    <array>
    <string>/usr/local/mysql/bin/mysqld_safe</string>
    <string>--user=mysql</string>
    </array>
  </dict>
</plist>

将您的 KeepAlive 密钥更改为

<key>KeepAlive</key>
<dict>
    <key>AfterInitialDemand</key>
    <true/>
    <key>Crashed</key>
    <true/>
    <key>SuccessfulExit</key>
    <false/>
</dict>

这将在 mysqld 崩溃或因错误代码终止时重新启动您的作业。 AfterInitialDemand 子项确保作业在加载时未启动。