Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.