Stop an osx service

Comments

4 comments

  • Avatar
    michiel

    Hi Jason,

    You can use stopOSXService in the following way:

    <stopOSXService>
    <serviceName>com.bitrock.sample</serviceName>
    </stopOSXService>

    You can find the name of the service using the following command:

    sudo launchctl list

    To run an OSX command without a script you can use runProgram:

     <runProgram>
    <program>ls</program>
    <programArguments>-lah</programArguments>
    </runProgram>

    The output of the command is stored in the program_stdout variable.

    Regards,

    Michiel

    0
    Comment actions Permalink
  • Avatar
    Jason

    Hi Michiel,

    I tried stopOSXService but it didn’t stop the service. I have confirmed that the service I am stopping does exist. Instead runProgram works for me.

    <runProgram>
    <program>launchctl</program>
    <programArgument>unload /Library/LaunchDaemons/com.bitrock.sample.plist</programArgument>
    </runProgram>

    Did I miss anything?

    Jason

    1
    Comment actions Permalink
  • Avatar
    Cam Hart

    Could we get an update on this @michiel?

    0
    Comment actions Permalink
  • Avatar
    michiel

    Hi Cam.

    Could you give more details about this issue? Could you create a sample service:

    <createOSXService>
    <keepAlive>1</keepAlive>
    <program>${installdir}/Sample.app/Contents/MacOS/sample</program>
    <programArguments>--service</programArguments>
    <serviceName>com.bitrock.sample</serviceName>
    <scope>system</scope>
    <username>daemon</username>
    <groupname>wheel</groupname>
    </createOSXService>

    And then try to stop it?

    <stopOSXService>
    <serviceName>com.bitrock.sample</serviceName>
    </stopOSXService>

    Regards,

    Michiel

    0
    Comment actions Permalink

Please sign in to leave a comment.