Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to figure out how to get two shell scripts to run automatically. One script to run when the mac is turned on. And another to run when the computer is about to shut down.

I'm guessing for launching, I should use launchd? Or is that overkill? I just need to run a self contained script, no variables being passed in. If so, any good references?

I can't seem to find a simple solution for running a script when the computer is shutting down. Any suggestions?


share|improve this question
Might want to modify the title to include the HUGE game changer fact in this post. "MAC" – francisswest Jun 10 '11 at 23:03
Thanks. On stackoverflow I've been told not to put tags in the title. Oh well. – RyanJM Jun 13 '11 at 14:25

I am unfamiliar with Mac OSX but it appears that instead of the traditional /etc/rc2.d it has /Library/StartupItems - you can place a startup script there (see random Internet blog or ancient Mac blog)_

By guesswork I'd expect /Library/ShutdownItems. However some people suggest adding commands to /etc/rc.shutdown.local.

But maybe you should wait for an answer from someone who actually knows about MacOSX :-)

share|improve this answer

Your Answer


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.