PDA

View Full Version : Command to gracefully restart OSX?


kLy
06-03-2007, 02:45 AM
Hi

I've had a look at this little tip and like it for booting into Windoze:
http://www.macinstruct.com/node/129

However it uses the "shutdown -r" command which just calls a *nix init 8. This kills all the OSX apps pretty ungracefully.

Is there a command to do an ordinary restart? Tried the applescript "tell app finder to restart" but that never works for me for some reason (just says whichever app I ran it from isn't stopping so couldn't log out).

Anyone got an idea?

Thanks! :)

hayne
06-03-2007, 03:38 AM
Tried the applescript "tell app finder to restart" but that never works for me for some reason (just says whichever app I ran it from isn't stopping so couldn't log out).

What do you mean "whichever app I ran it from" ?
You should compile the AppleScript to a double-clickable app (e.g. from Script Editor) and then just double-click it to run it.

acme.mail.order
06-03-2007, 05:09 AM
However it uses the "shutdown -r" command which just calls a *nix init 8. This kills all the OSX apps pretty ungracefully.
True, but you should ask yourself "is this a problem?" The background processes will deal with the signal properly, so unless I was running a GUI database I wouldn't worry about it. Word won't particularly care about a kill -9, Mail MIGHT get upset if you shoot it at just the wrong time, but the `shutdown` signal isn't instant - programs do have time to flush data and close files.

tw
06-03-2007, 09:34 AM
Is there a command to do an ordinary restart? Tried the applescript "tell app finder to restart" but that never works for me for some reason (just says whichever app I ran it from isn't stopping so couldn't log out).


the restart command is deprecated in the finder - should still work, but the approved version now is through System Events:


tell application "System Events"
restart
end tell


as Hayne pointed out, you must compile this as an applescript application (or run it as a script from a special context, like the the Finder's script menu). if you try to run it from the script editor, the editor will be stuck running the script when it receives the shutdown command, and that will give you the 'isn't stopping' error.