Forcing a shutdown in OSX

Posted by: andym

Forcing a shutdown in OSX - 20/11/2007 20:00

So I've written a great little script that makes a set of symlinks that point to specific folders depending upon the day. This runs off a cron tab on an OSX server at 10 past midnight every night. The folder containing these symlinks is shared over NFS to a bunch of other macs. The problem I have is that although the symlinks update, you can see that in a terminal window, the little alias folders in Finder don't. It seems only a disconnect and reconnect to the share or a restart updates the alias folders.

So my question, is there any way to force a shutdown of a machine regards of anything running on it? The lusers are too stupid to remember to shut them down each night.
Posted by: wfaulk

Re: Forcing a shutdown in OSX - 20/11/2007 20:03

Make this Applescript script:

Code:
ignoring application responses
tell application "Finder"
shutdown
end tell
end ignoring


And then run it from cron using the "open" command.
Posted by: andym

Re: Forcing a shutdown in OSX - 20/11/2007 20:19

shutdown needed to be changed to shut down. But the apps still sit there asking for confirmation to quit.
Posted by: wfaulk

Re: Forcing a shutdown in OSX - 20/11/2007 20:43

Hmm. That's what the "ignoring" is supposed to avoid, obviously.

I assume you've tried the shutdown or reboot command.

How about "System Events" instead of "Finder"?
Posted by: drakino

Re: Forcing a shutdown in OSX - 21/11/2007 04:05

Terminal command "shutdown -h now" to shutdown or "shutdown -r now" for a restart. No GUI confirmations so unsaved work will be lost. But to OS X, it is a proper shutdown, just like any other Unix OS.
Posted by: andym

Re: Forcing a shutdown in OSX - 21/11/2007 19:26

Quote:
Terminal command "shutdown -h now" to shutdown or "shutdown -r now" for a restart. No GUI confirmations so unsaved work will be lost. But to OS X, it is a proper shutdown, just like any other Unix OS.


That did it, stuck it in root's crontab and prefixed it with /sbin/

Now all the machines power off at 5 to midnight every night