Run a terminal command on startup and in background

Discussion in 'Mac Programming' started by SkillsToShow, Apr 12, 2010.

  1. SkillsToShow macrumors regular

    Joined:
    Aug 23, 2008
    Location:
    California
    #1
    I have this command that I run in the terminal that I want to run in the background and startup automatically when I turn my computer on. I have done a few google searches and it seems to be extremely complicated. What would be the best way to do this?

    Here is the command I run in terminal:

    Code:
    cd '' && '/usr/local/bin/pythonw' '/Applications/Python 2.6/pyWHATauto-v1.14/Whatauto.py'
     
  2. calderone macrumors 68040

    calderone

    Joined:
    Aug 28, 2009
    Location:
    Seattle
    #2
    On startup or login?

    For startup, you want to create a LaunchDaemon.

    For login, create a LaunchAgent, For a user specific launch agent, put it in the ~/Library/LaunchAgents. For a system wide launch agent drop it in /Library/LaunchAgents.

    Creating things for launchd is covered here: http://www.afp548.com/article.php?story=20050620071558293
     
  3. SkillsToShow thread starter macrumors regular

    Joined:
    Aug 23, 2008
    Location:
    California
    #3
    I actually want it to start up when I login. I googled Launch Agent and found this code:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    	<key>Label</key>
    	<string>com.apple.TextEdit</string>
    	<key>OnDemand</key>
    	<false/>
    	<key>ProgramArguments</key>
    	<array>
    		<string>/Applications/TextEdit.app/Contents/MacOS/TextEdit</string>
    	</array>
    </dict>
    </plist>
    Is this something I can use to startup on login? and run in the background? I have no programming knowledge so this kind of stuff is pretty new to me.
     

Share This Page