Creating a command that starts when OS X boots

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

  1. macrumors member

    Joined:
    Oct 25, 2007
    #1
    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. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #2
    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. macrumors 6502a

    Cybix

    Joined:
    Feb 10, 2006
    Location:
    Western Australia
    #3
    you could use a cron.

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

    DoFoT9

    Joined:
    Jun 11, 2007
    Location:
    Singapore
    #4
    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. macrumors 6502

    Joined:
    Mar 8, 2004
    #5
    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. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #6
    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. macrumors newbie

    Joined:
    Sep 8, 2007
    #7
    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. thread starter macrumors member

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

Share This Page