Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question

1 Answer 1

up vote 1 down vote accepted

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

share|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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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