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

614 views Asked by At

I'm adding a launchd file for MySQL that I don't want to be automatically started. Just wondering what I should change in the file.

/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>
1

There are 1 answers

0
LCC On BEST ANSWER

Change your KeepAlive key to

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

This will restart your job when mysqld has crashed or terminated with an error code. The AfterInitialDemand subkey makes sure the job is not started when loaded.