Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have several services set up in launchctl and they all start at boot and restart automatically whenever they stop for any reason. That's great so far.

But sometimes I want one of the services to quit and not restart for a while.

Is there a recommended way to do that apart from removing the service from launchctl (which also stops it immediately, which I don't want to do)?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

I found a way to do it. I added the following to the plist file.

Instead of

    <key>KeepAlive</key>
    <true/>

I made it

    <key>KeepAlive</key>
    <dict>
      <key>SuccessFulExit</key>
      <false/>
    </dict>

Just setting KeepAlive to false would interfere with the job starting at all. (It was presumably waiting to be called by someone.) But KeepAlive's status can also be determined at runtime. This service now restarts automatically when it quits for no good reason (i.e. when it is killed) but not when it quits for a reason (i.e. was shut down regularly). This is what I need.

share|improve this answer
add comment

So you want to kill the process without restarting it but you don't want to kill it immediately? Does that actually make any sense to you?

No, launchd has no such feature.

share|improve this answer
    
You think it doesn't make sense to want to shut down a service without killing it immediately? I think it only doesn't make sense if you do not differentiate between shutting down a service and killing it. –  Andrew J. Brehm Apr 3 '10 at 15:49
add comment

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.