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 trying to use PathState to start and stop a daemon on Mac OSX. It start when I create a file called /var/cache/myjob/run. However when the file is removed, the daemon doesn't stop again.

How do you use PathState to make it stop?

The launch configuration

<?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>StandardOutPath</key>
        <string>/var/log/tomcat/server.log</string>
        <key>StandardErrorPath</key>
        <string>/var/log/tomcat/server.log</string>
        <key>Label</key>
        <string>com.clcbio.clcserver</string>
        <key>WorkingDirectory</key>
        <string>/Users/tomcat/tomcatdist</string>
        <key>GroupName</key>
        <string>daemon</string>
        <key>KeepAlive</key>
        <dict>
            <key>PathState</key>
            <dict>
                <key>/var/cache/tomcat/run</key>
                <true />
            </dict>
        </dict>
        <key>ProgramArguments</key>
        <array>
            <string>/bin/bash</string>
            <string>-c</string>
            <string>java -Xmx512m -XX:MaxPermSize=192m -Djava.awt.headless=true
                -Djava.library.path=./native
                -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
                -Djava.util.logging.config.file=./conf/logging.properties
                -Djava.endorsed.dirs=./endorsed -Dcatalina.base=./
                -Dcatalina.home=./ -cp bin/bootstrap.jar:./conf
                org.apache.catalina.startup.Bootstrap</string>
        </array>
        <key>UserName</key>
        <string>tomcat</string>
    </dict>
</plist>
share|improve this question

1 Answer 1

up vote 0 down vote accepted

You can't do that with a launchd item. A launchd item specifies the conditions under which a program should be started (and maybe restarted if it exits), but not the conditions under which it should be stopped. You'll need to use some other mechanism to stop the process. (Note that you can stop a running daemon with e.g. sudo launchctl stop com.clcbio.clcserver)

share|improve this answer
    
> If the value of the key is true, then the job will be kept alive as > long as the path exists. It will take 3-4 seconds to stop the job. No need to use launchctl stop or unload command. –  Parag Bafna Oct 16 '13 at 12:11

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.