How do I set Terminal scripts to run at start up on Mac OS X Snow Leopard?

空扰寡人 提交于 2019-12-21 07:56:35

问题


Hello I'm using Mac OS X 10.6.8. How can I set some simple Terminal commands to run on start up as if I was opening up Terminal and putting those commands in myself? I basically need to start a few server daemons on start up. The commands I use in Terminal to manually start them look like sudo ruby myrubyserverscript_control.rb start. I apologize in advance if this is super obvious or already answered on here a million times in some way I don't know enough to recognize.


回答1:


Here are two different things:

  1. you want run a script after the system startup (boot), or
  2. when you logging in

for run a script at boot, you should put one XML config file into /Library/LaunchDaemons (and the launchd process will run the script at the boot time)

for run a script after you logging in - see this: https://stackoverflow.com/a/6445525/632407




回答2:


Open System Preferences and go to the Users and Groups / Login Items tab. You can add a scipt with the + button or drag it to the list of items. Usually scripts end in .command that are used in this context but they are just bash scripts. I suppose you could use any script that is executable and has the correct #! line.



来源:https://stackoverflow.com/questions/12534379/how-do-i-set-terminal-scripts-to-run-at-start-up-on-mac-os-x-snow-leopard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!