0

So I have a plist to keep monit running:

<?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>com.monit.service</string>
    <key>KeepAlive</key>
    <true/>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/Cellar/monit/5.10/bin/monit</string>
        <string>-d 60</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/var/log/monit.log</string>
</dict>
</plist>

I can do launchctl load /Library/LaunchDaemons/com.monit.service.plist to start the service, but launchctl unload /Library/LaunchDaemons/com.monit.service.plist will not stop it. I can see that the process keeps running no matter what I do.

The process shows up like this(note how the binary path doesn't show up, only the last argument):

output of ps aux:

root            14656   0.0  0.0  2482248   1656   ??  S     6:55PM   0:00.09 -d 60

How can I write the launchd plist so that it will actually stop the freaking process whenever I want it to stop?

0

Get rid of the -d 60 arguments and use the launchd key StartInterval instead. Also make sure the process does not daemonize itself. According to the monit man page this is accomplished by using the -I option.

  • For the record, my monitrc file only had this:set daemon 60 and I needed this: set init set daemon 60. So essentially, I was daemonizing monit. – marcoamorales Jan 27 '15 at 2:12
0

I suspect since it is running from /Library/LaunchDaemons/ and not the user ~/Library/LaunchAgents you need to use sudo to issue the command with permission.

sudo launchctl unload /Library/LaunchDaemons/com.monit.service.plist

  • I'm running these commands as root, so I don't think that's the issue. – marcoamorales Jan 23 '15 at 5:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .