Benches macOS

2

Executing terminal command at startup

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

What is the easiest way to execute a terminal command when OSX starts up?

2 replies

Sign in or join Beachball Help to reply.

  1. 0

    baltwo

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Use a login hook as described in http://www.bombich.com/mactips/loginhooks.html BTW, you should post Unix and Terminal queries to the Unix forum under OS X Technologies.

  2. 0

    KJK555

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    OS X has used Launchd to run startup items since Tiger (10.4). Create a .plist for the program

    you want to run and putting it in the /Library/launchAgents or the $HOME/Library/LaunchAgents

    directory, if you only want it to run at user login. Optionally, for user startup items, you can add

    the command to the Account login items, but it has to be in the form of a standalone unix script

    or automator app to work correctly as an Account login item.

    Here are some background resources on launchd:

    http://www.macgeekery.com/tips/allabout_launchd_items_and_how_to_make_oneyourself

    http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemS tartup/Articles/LaunchOnDemandDaemons.html

    http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/m an5/launchd.plist.5.html

    Here is a Gui app that can help you create launchd items:

    http://sourceforge.net/projects/lingon/files/

    Here is a thread on using Account login items to launch scripts and automator apps:

    http://discussions.apple.com/message.jspa?messageID=11569184#11569184

    Now, go start something. 😉