Run a command on start up 1 time

Discussion in 'Mac Programming' started by quanganhct, Oct 17, 2011.

  1. quanganhct macrumors member

    Dec 29, 2010

    Here is my issue. I wanna run my script on start up. So I follow every steps I found out ( abour launchd)

    This is my plist file :
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
    <plist version="1.0">
        <string>QAScript</string> <!-- org.mongodb.mongodb perhaps? -->




    However, I want that my script executed only one time, but it seem that it was executed continuously. So, Is there any way to make it fired just one time on start up ? Thanks a lot
  2. kainjow Moderator emeritus


    Jun 15, 2000
    OnDemand is deprecated, try replacing it with KeepAlive.
  3. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    OnDemand is the wrong key for launching once. The correct key is RunAtLoad.

    Quoting from the man page for launchd.plist:
    RunAtLoad <boolean>
    This optional key is used to control whether your job is launched once at
    the time the job is loaded. The default is false.
  4. larkost macrumors 6502a

    Oct 13, 2007
    Your <label> should exactly match the filename of the plist, minus the '.plist' at the end. Otherwise you can get launchd very confused and unable to unload or reload your item.
  5. quanganhct thread starter macrumors member

    Dec 29, 2010
    I tried KeepALive = false too, but it's still not working.
  6. subsonix macrumors 68040

    Feb 2, 2008
    If you just want your script to run once every time you log in, you can add it to login items in system preferences / accounts and forget about launchd.

Share This Page