0

I am using launchd to start mysql on boot, it is working fine. I am able to stop and start the service using 'launchctl unload' and 'launchctl load' commands. Also I am able to start the service by typing 'mysqld_safe' command in terminal. But, if I stop the service through 'launchctl stop' and then start the service through 'mysqld_safe' command, I am unable to stop the service through 'launchctl stop'. Is this possible? What I am doing wrong here?

My Plist is:

<?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>mysql.service</string>
        <key>ProgramArguments</key>
        <array>
                <string>/path/to/mysql/bin/mysqld_safe</string>
                <string>--defaults-file=/path/to/mysql/my.cnf</string>
                <string>--port=3306</string>
                <string>--socket=/path/to/mysql/tmp/mysql.sock</string>
                <string>--datadir=/path/to/mysql/data</string>
                <string>--log-error=/path/to/mysql/data/mysqld.log</string>
                <string>--pid-file=/path/to/mysql/data/mysqld.pid</string>
       </array>
       <key>RunAtLoad</key>
       <true/>
       <key>KeepAlive</key>
       <false/>
       <key>UserName</key>
       <string>_mysql</string>
       <key>GroupName</key>
       <string>_mysql</string>
    <key>StandardOutPath</key>
    <string>/tmp/mysql_start.out</string>
    <key>StandardErrorPath</key>
    <string>/tmp/mysql_start.err</string>

</dict>
</plist>

Command used to start mysql through terminal is:

mysqld_safe --defaults-file=/path/to/mysql/my.cnf --port=3306 --socket=/path/to/mysql/tmp/mysql.sock --datadir=/path/to/mysql/data --pid-file=/path/to/mysql/data/mysqld.pid
1

This is intended behavior. Issuing launchctl stop for a job which has not been loaded does not work.

| improve this answer | |
  • To expand on this: if it wasn't started by the launchd daemon, it's not a launchd job can't be managed with launchctl -- it's just an independent process that happens to be running the same program that your launchd job would run. – Gordon Davisson Sep 5 '13 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.