Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm unfamiliar with how this works with OSX. I just want a script to run whenever the OS loads up. Simple script to restart my servers via python. There's about 4 of them. So how do I run commands like the following at startup?

cd Applications/MyServer
python myserver.py

cd Applications/MyOtherServer
python myotherserver.py

and so on? I don't know where to place the script, or what type of file to save it in :/

UPDATE: ok i figured out that its just a matter of dumping that into a text file with an extension of .sh. Then running the sh myScript.sh command. But I'm still hunting for an answer how to get this to run at startup.

UPDATE: here's my script to start my servers. I'm still looking for a way to get it into startup. had to do them in separate windows as the application will then run in this window.

# Start up Server 1
osascript -e 'tell app "Terminal"
    do script "python /applications/Server1/server1.py"
end tell'

# Start up Server 2
osascript -e 'tell app "Terminal"
    do script "python /applications/server2/server2.py"
end tell'

# Start up Server 3
osascript -e 'tell app "Terminal"
    do script "python /applications/server3/server3.py"
end tell'
share|improve this question

Note: I didn't test this but it has a chance of actually working ;)

  • create a runnable script
  • go to Preferences -> "Users and Groups" -> Your user -> "Login Items" tab
  • Drag and drop your script into the list of items to run.
  • reboot
share|improve this answer
up vote 0 down vote accepted

lol ok...

so the answer was simply to make the .sh file executable by running

chmod a+x LaunchServers.sh

Then associating the file type to run with terminal, then adding it to startup items under Users & Groups in system prefs. Tested and working.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .