Creating a command that starts when OS X boots

Discussion in 'Mac Programming' started by stakis, Apr 14, 2008.

  1. stakis macrumors member

    Oct 25, 2007
    Hey all,

    I haven never done this before so I'd like some help

    I'm looking to have Terminal load and run a command and the quit when OS X boots... kinda like a start up app..

    is there any way this can be done?

    please if you can give me a detailed instruction that would be great!!!

    Thanks again!!!
  2. HiRez macrumors 603


    Jan 6, 2004
    Western US
    Probably someone can provide you with more details, but start by reading up on launchd, which is what OS X uses to do such things. You might also be able to run an AppleScript, but I think all startup processes have to run with root privileges. Also check out Lingon, which is a free GUI application to help you create and manage launchd processes.
  3. Cybix macrumors 6502a


    Feb 10, 2006
    Western Australia
    you could use a cron.

    @reboot userid /path/to/app
  4. DoFoT9 macrumors P6


    Jun 11, 2007
    out of curiosity...

    that would only start once the user has logged in?? or can you put it at the OS level and it starts after the rest of the computer has loaded??

    e.g. can you have it load while still at the login window?
  5. Mac_Max macrumors 6502

    Mar 8, 2004
    Follow this guide to make your shell script (shell referring to the terminal), and then use the Login Items section in the Accounts Preference Pane to start it at boot.
  6. HiRez macrumors 603


    Jan 6, 2004
    Western US
    But that won't run the script at boot, only at login time, for a particular user (unless they added some option for this in Leopard I'm not aware of). The OP said they wanted to run it at boot time.
  7. bloomberg macrumors newbie

    Sep 8, 2007
    I'm a recent switcher so there may be a better (read faster) way. It takes a few steps to create a startup script under osx.
    • Create a directory under /Library/StartupItems/yourscript
    • Create a *.plist file for your script in yourscript dir that defines your script parameters
    • Create a startup script in yourscript dir (it may also stop & restart)
    Read about the details here. As someone who uses linux I certainly appreciate why it's done this way. However, a simple helper script to generate the most common cases would be nice instead of copying and pasting every time. Good luck!
  8. stakis thread starter macrumors member

    Oct 25, 2007
    Hey all thanks for the help... managed to get it done!!!

Share This Page