Go Back   The macosxhints Forums > OS X Help Requests > System



Reply
 
Thread Tools Rate Thread Display Modes
Old 07-09-2002, 03:19 AM   #1
jmcward
Prospect
 
Join Date: Jul 2002
Posts: 3
Question "Shutdown Items" replacement for OSX

Hi All,

Is there a way to run an AppleScript just before shutdown? Something
equivalent to the "Shutdown Items" folder in OS 9.x.

I thought I would be able to find the answer to this in about 2 min. but
so far its eluded me.

Any solutions or Ideas.

Thanks for any help.

Jeff
jmcward is offline   Reply With Quote
Old 07-13-2002, 05:09 PM   #2
jpkelly
Triple-A Player
 
Join Date: Mar 2002
Location: San Francisco
Posts: 57
26 views and no replies?!?!?!
Is there really no one out there with an answer to this question?
jpkelly is offline   Reply With Quote
Old 07-13-2002, 05:28 PM   #3
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
answer

there is no "shutdown items" paradigm.

before you shutdown, run your shutdown script

or, don't shutdown.
mervTormel is offline   Reply With Quote
Old 07-14-2002, 05:08 AM   #4
jmcward
Prospect
 
Join Date: Jul 2002
Posts: 3
I'm running an AppleScript on a server to control the shutdown process.

So, I'm not at the computer when it needs to happen.
jmcward is offline   Reply With Quote
Old 07-14-2002, 08:38 AM   #5
JayBee
Major Leaguer
 
Join Date: Jan 2002
Location: Edinburgh, Scotland
Posts: 437
Quote:
Originally posted by jmcward
I'm running an AppleScript on a server to control the shutdown process.

Could you not just use this AppleScript to run your shutdown items?

Or am I missing the point? Why do you need to shutdown the server anyway, and what are you trying to achieve?
__________________
JayBee
--

It's all relative, you know
JayBee is offline   Reply With Quote
Old 07-14-2002, 09:00 AM   #6
dsk
Triple-A Player
 
Join Date: Jan 2002
Location: Philadelphia, PA
Posts: 223
Why don't you set a cron job to run a shell script which launches the AppleScript you want and then shuts down the machine? Say, at midnight each night, run SomeScript, then shutdown. Is this the kind of thing you want, or am I missing the point?

David
dsk is offline   Reply With Quote
Old 07-14-2002, 11:34 AM   #7
jpkelly
Triple-A Player
 
Join Date: Mar 2002
Location: San Francisco
Posts: 57
Yeah i am realizing that a cron job is the way to go.
jpkelly is offline   Reply With Quote
Old 07-14-2002, 04:44 PM   #8
jmcward
Prospect
 
Join Date: Jul 2002
Posts: 3
Without getting into too much detail, there is a server and a client relationship. The server reports to the clients that the server is shutting down and the client logs off the server when a restart is made. I'm trying to keep it simple and user installable (i.e. easy) and free. I want something like "Shutdown Items" in OS 8-9.x which works perfect.

Any approach to this will work including a small freeware app. that waits for the shutdown process to start and then can run the AppleScript before shutdown has occurred.

It's hard to believe that something that was so simple in OS 9 is such a pain is OS X.

I hope Apple brings back that feature.

Last edited by jmcward; 07-14-2002 at 04:47 PM.
jmcward is offline   Reply With Quote
Old 07-14-2002, 04:54 PM   #9
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
this is still very unclear. what is shutting down? a server? why is it required that a client shutdown if a server shuts down? if a server shuts down, connected clients don't have much choice, er, any choice.

there was nothing magical about the "shutdown items" folder in pre-OSX. if there were items in there, they would be executed locally, on shutdown.

can you explain more clearly what it is you're trying to accomplish?

Last edited by mervTormel; 07-14-2002 at 04:57 PM.
mervTormel is offline   Reply With Quote
Old 07-14-2002, 09:05 PM   #10
jpkelly
Triple-A Player
 
Join Date: Mar 2002
Location: San Francisco
Posts: 57
I am working on a script to remember where all my desktop icons are/were before shutting the machine down and move them to where they were on startup. Specifically my numerous disks which tend to get spread around when the desktop gets cluttered.
Pretty trivial.

There was a script that did this in OS 9 but it is broken in OS X.
Speaking of broken:
I just figured out that the Applescript "position" property of items applies to a finder window only and not the actual desktop. (in OS 9 it applied to both)
Any idea where the icon positions for desktop icons are stored or can be found?

Anyway there is probably a better way to do this.
If it is worth doing at all.
I guess being more organized would reduce the clutter on my desktop.
jpkelly is offline   Reply With Quote
Old 07-15-2002, 12:13 PM   #11
JayBee
Major Leaguer
 
Join Date: Jan 2002
Location: Edinburgh, Scotland
Posts: 437
edit : oops - should really read posts before I reply to 'em. Disregard, move along. Nothing to see here, no sireee.

__________________
JayBee
--

It's all relative, you know
JayBee is offline   Reply With Quote
Old 07-15-2002, 01:41 PM   #12
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 31,939
clarification (with details) needed

I also would like to get more details on what you are trying to do.
Part of the confusion stems from the use of the word "server" which can refer to the machine or to a program (e.g. a database server). If it is the latter, I don't see why that program can't notify its clients on it own. It knows it is shutting down, so it can just tell its clients. If it is the machine which is shutting down, then each program running on that machine will be notified that it is about to be shutdown - this is usually when interactive programs put up a dialog asking if the files should be saved.
hayne is offline   Reply With Quote
Old 05-18-2006, 09:42 PM   #13
cornelius
Prospect
 
Join Date: May 2006
Posts: 2
Running things at shutdown.

I found a clean way to run programs at shutdown: simply register whatever command you want to execute as a service. A service has a Start and Stop functions. Stop function is executed upon shutdown.

To make your own service: create a directory in /System/Library/StartupItems/ or /Library/StartupItems/; place a file of the same name as the directory there with the following contents:

Code:
#!/bin/sh

. /etc/rc.common

StartService ()
        {
         # what to do on boot (can be empty)
        }

StopService ()
        {
         # what to do on shutdown (can be empty)
        }

RunService "$1"
This file has to be executable, i.e. chmod a+x filename. Then create a file by the name StartupParameters.plist with the following contents:

Code:
{
  Description     = "Name of your service goes here";
  Provides        = "Whatever your service provides goes here";
  Uses            = "Disks";
}
That's it. You can read more on what those entries in quotes mean here.

This works on my MacBook Pro OSX 10.4.6.
cornelius is offline   Reply With Quote
Old 05-18-2006, 11:09 PM   #14
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 31,939
Quote:
Originally Posted by cornelius
create a directory in /System/Library/StartupItems/ or /Library/StartupItems/

Nobody other than Apple should be putting things under /System/Library
The only correct place for you to put your own startup items is /Library/StartupItems
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 05-18-2006, 11:46 PM   #15
cornelius
Prospect
 
Join Date: May 2006
Posts: 2
Shutdown items

Yeah, you're probably right. Use /Library/StartupItems. Also, I forgot parentheses around the last two lines of the last file. It should read

StartupParameters.plist
Code:
{
  Description     = "Name of your service goes here";
  Provides        = ("Whatever your service provides goes here");
  Uses            = ("Disks");
}
cornelius is offline   Reply With Quote
Old 10-15-2006, 10:59 AM   #16
notaclone
Prospect
 
Join Date: Jul 2004
Posts: 9
Hi Cornelius,

I came across this thread and it got me thinking...(hope you are still subscribed)

A common problem in OSX for artists and font mongers is that the font cache frequently becomes corrupt and they are too <whatever> to empty the cache manually.

Since the system must be rebooted after clearing caches, then the best point at which to schedule this is at shutdown, and executed only monthly for a regular tune up. (I was thinking of attaching a script to Macaroni for scheduling, but they only have an option for at wake, not at shutdown.)

Ideally, the script is invoked monthly after a user chooses shut down, and it asks to clear the font cache, allowing a cancel (otherwise it will proceed after a specific time).

Do you think this is doable?
notaclone is offline   Reply With Quote
Old 10-28-2009, 10:20 PM   #17
gadsden
Prospect
 
Join Date: Oct 2009
Posts: 20
I came across this really old thread because I am trying to create a "shutdown item" in 10.6. Does this still apply with 10.6? If yes, can someone put this into laymens terms? I am having a little difficulty understanding some of the instructions, particularly what type of files need to be created and how to make the file executable.

Hoping someone can help!
gadsden is offline   Reply With Quote
Old 10-29-2009, 08:47 AM   #18
Andreas~
Triple-A Player
 
Join Date: Sep 2008
Location: UnKnown
Posts: 143
I hope you will find a simple AppleScript app easy to create. Launch 'Script Editor' which you should find in /Applications/AppleScript/. Copy and paste the code in the link below. Hit <Enter> to compile it -- the text should show in different colors, and with no error message. Save it as an Application with just one option selected, "Stay Open".

Modify the code to do what you want at shutdown time, but do not try to launch anything in a shutdown script -- that will either cancel the shutdown process or create chaos. With that proviso see my post at

http://discussions.apple.com/thread....88514&#7088514
__________________
Andreas
Andreas~ is offline   Reply With Quote
Old 10-29-2009, 10:03 AM   #19
biovizier
All Star
 
Join Date: May 2004
Location: london on ca
Posts: 930
I can't speak for 10.6 but '/private/etc/rc.shutdown.local' works in 10.4 and 10.5 (I believe 'rc.shutdown' worked in 10.4 but not 10.5).

It may or may not be appropriate depending on what sorts of actions are required, and also whether you effectively want a shutdown item or a logout item (this thread is primarily concerned with the former)...
biovizier is offline   Reply With Quote
Old 10-29-2009, 10:53 AM   #20
cwtnospam
League Commissioner
 
Join Date: Jan 2005
Posts: 8,475
I don't understand where the problem lies here. If you want to run a script and then shutdown, then why can't the script perform the shutdown when it's done?

Am I missing something?
cwtnospam is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 01:32 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.