Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6203913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:59:55+00:00 2026-05-24T04:59:55+00:00

I am attempting to set up a .plist file for use with launchctl on

  • 0

I am attempting to set up a .plist file for use with launchctl on OSX. When run from the command line (not using launchctl), our application is executed as:

/path/to/ourapp

… and to terminate our application, we type:

/path/to/ourapp -k

… which causes the new instance of ourapp to properly kill the previous instance that is running.

Now I set up a .plist file to control execution of the application via launchctl, as follows:

// start.plist
<dict>
    <key>Disabled</key>
        <false/>
    <key>Label</key>
        <string>ourapp</string>
    <key>ProgramArguments</key>
        <array>
            <string>/path/to/ourapp</string>
        </array>
    <key>OnDemand</key>
        <false/>
    <key>UserName</key>
        <string>daniel347x</string>
    <key>SHAuthorizationRight</key>
        <string>system.preferences</string>
</dict>

… and I execute it at the command line, as follows:

launchctl load /path/to/start.plist

This works successfully to launch the application.

Unfortunately, when creating a stop.plist, as follows (the only difference is the addition of the -k argument):

// stop.plist
<dict>
    <key>Disabled</key>
        <false/>
    <key>Label</key>
        <string>ourapp</string>
    <key>ProgramArguments</key>
        <array>
            <string>/path/to/ourapp</string>
            <string>-k</string>  // <-- only difference is adding this argument
        </array>
    <key>OnDemand</key>
        <false/>
    <key>UserName</key>
        <string>daniel347x</string>
    <key>SHAuthorizationRight</key>
        <string>system.preferences</string>
</dict>

… and executing via

launchctl unload /path/to/stop.plist

… the application does NOT terminate … therefore, it seems that when using launchctl, the application is not being executed equivalently to

/path/to/ourapp -k

Can someone tell me what launchctl unload is really doing – i.e. is it calling the application from the command line with the given arguments, or not – and what I can do to get my stop.plist to work when using launchctl unload, given whatever it is doing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:59:55+00:00Added an answer on May 24, 2026 at 4:59 am

    High level

    No, “launchctl unload” on OSX does not pass “ProgramArguments” to the target application. It removes the plist from the ones that launchd is running.

    Short answer

    I’m not sure you are using launchctl and launchd the way it was designed, but try:

    launchctl load /path/to/stop.plist
    

    Longer answer

    The launchctl command is used to control which plists launchd runs at any given time. When you issue:

    launchctl load /path/to/start.plist
    

    the plist is loaded into launchd and your “ourapp” is trigged. A critical point is that unless “ourapp” unloads the start.plist, it will still be running in launchd. You can check this by viewing the output from:

    launchctl list
    

    The reason your call to unload the stop.plist didn’t have any effect is that it was never loaded into launchd to begin with. To be able to stop it, you must first start it with:

    launchctl load /path/to/stop.plist
    

    The trick with this is that once you do this, both your start.plist and stop.plist will be running. Obviously, I haven’t tested your app/setup, but this could cause weird behavior. Also, I’m not sure what running the “load” again on your start.plist would do since it would already be running.

    Form what you’ve described here, it looks like launchd and launchctl might not be the best approach. If you want to stick with it, I think you would need to add system calls into your “ourapp” so that when it gets issued the kill command it also unloads both the start and the stop plist. Or, write a proxy script that unloads the plists and then calls your “ourapp -k”. That way, the next time you use “launchctl load /path/to/start.plist” you won’t be trying to start something that’s already running.


    One other note. You might have just been using the “ourapp” as place holders, but it’s worth pointing out that you probably want to use unique Label names. If nothing else, it’ll help you keep track of them with “launchctl list”. I don’t know if launchd itself would have an issue with duplicate names, but it seems safest to avoid the possibility.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to set up a symbol proxy using symproxy.dll from Debugging Tools for
I am attempting to run the following command in KornShell (ksh): set -A INDEXES
I am attempting to set a value in a textarea field using jquery with
I am attempting to set up my own project using a third party library
I have a Perl script that I'm attempting to set up using Perl Threads
I am attempting to use the code-behind (Page_Load or PreRender) to set a date-time
Attempting to set up Samba + OpenLDAP using nss_ldap. After joining Windows7 to Samba
I'm attempting to set up my unit testing environment to use DbUnit. I'm having
I'm attempting to set up a simple Mac-based 2D tiling engine, using a 2D
I am attempting to set a revprop using svnadmin setrevprop /path/to/repos propname propfile -r

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.