How to make programs run at shutdown?

havic

Windsurfer Nerd
I have a command-line program I wrote in C that I need to be executed everytime the computer shuts down. On one of my friends computers there is a folder called rc (I think) in the /etc directory, and you can place programs in that and they will be executed at shutdown.
Mac OS X however doesn't seem to have one of those.

Alternatively, if there is no shutdown scripts folder in Mac OS X, which it looks like there isn't, I can just make my application sit idle until it recieves a signal from the computer that it is going to shutdown, and I could have it run when it recieves that signal. Does anyone know if Mac OS X sends such a signal, and if so how I would recognise it?

This is my first post here. Hi everyone ;)
 
Try writing an Apple Script that runs your program, then shuts down your computer. Then, when you want to shut down, just launch this script.
 
Oh thanks floris, I had seen the Loginhooks before but had then been told that there was no logout equivelant. Thanks for correcting me :)
 
Yeah log* hooks are really cool.

In a similar vein I have a little project of my own. I have a UPS (can't remember which off the top of my head but it's included OS X software is called PowerChute) into which is plugged BOTH my iMac-which has the USB connection-and my RedHat server.

Now, I want to find a way to send a shutdown command to my RedHat server when my iMac goes down, but only when it goes down as a result of PowerChute telling it to; i.e., I don't want to reboot my server when my iMac restarts for softwareupdate.

As far as I can see, PowerChute seems to have the halt hard-coded into the monitoring daemon (that is, there is no user-editable shutdown script that I can find and edit).

Is there any easy solution to this problem?
 
Back
Top