image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #1  
Old January 4th, 2004, 05:05 PM
havic's Avatar
Windsurfer Nerd
 
Join Date: Jan 2004
Location: Auckland, NZ
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
havic is on a distinguished road
Question How to make programs run at shutdown?

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
Reply With Quote
  #2  
Old January 5th, 2004, 05:49 AM
Arden's Avatar
Don't drink and derive.
 
Join Date: Dec 2002
Location: San Francisco
Posts: 7,743
Thanks: 0
Thanked 0 Times in 0 Posts
Arden is on a distinguished road
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.
__________________
System:
• 2.5 GHz MacBook Pro Core 2 Duo, 4 GB RAM, 200 GB hard drive, runs 10.5.4
• 1.6 GHz iMac G5, 1.5 GB RAM, 250 GB hard drive, runs 10.4.11
• iPhone, 4 GB, OS X 2.0.2
Reply With Quote
  #3  
Old January 8th, 2004, 07:26 AM
Registered User
 
Join Date: Sep 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
floris is on a distinguished road
create a logout-hook

look at: http://developer.apple.com/documenta...stomLogin.html

it's simple!
Reply With Quote
  #4  
Old January 9th, 2004, 12:36 AM
havic's Avatar
Windsurfer Nerd
 
Join Date: Jan 2004
Location: Auckland, NZ
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
havic is on a distinguished road
Oh thanks floris, I had seen the Loginhooks before but had then been told that there was no logout equivelant. Thanks for correcting me
Reply With Quote
  #5  
Old January 9th, 2004, 12:08 PM
michaelsanford's Avatar
Psycholinguist
 
Join Date: Oct 2002
Location: Ottawa/Montrιal
Posts: 2,174
Thanks: 0
Thanked 0 Times in 0 Posts
michaelsanford is on a distinguished road
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?
__________________
michaelsanford.com • Blog • Twitter • Tumblr • LinkedIn
• iMac Aluminum 24" |
MacOS X 10.5-current | 3.06 GHz Intel Core Duo | 4 GB RAM | 1 TB HDD
• iBook G4 1.42 GHz | MacOS X 10.5-current | 1 GB RAM, 100 GB HDD
• AMD Athlon64 3500+ | Slackware 12 (2.6.21.5-smp) | 2 GB RAM, 2•120 GB RAID 1, 2•500 GB RAID 0
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 09:33 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.