Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is this correct command to shutdown Leopard after 60min?

sudo shutdown -h 60

share|improve this question

1 Answer 1

up vote 4 down vote accepted

The correct usage from the command line for shutting down Mac OS after 60 minutes is:

sudo shutdown -h +60

That is not the method that Apple recommends using, though it is probably the best way on a headless server. (Update: See comment and link from @radius - the use of shutdown is recommended by Apple's server CLI admin guide). From the Command Line Junkies Guide to Mac OS X (the site is out of date but the reference to using osascript is current):

Rebooting and Shutting Down

Although you can reboot or shut down Mac OS X systems via the traditional halt, reboot and shutdown commands, the Apple-recommended way of turning off the computer remotely is to send the Finder an Apple Event. This can be accomplished using the osascript command to run an AppleScript:

osascript -e 'tell application "Finder" to shut down'

or

osascript -e 'tell application "Finder" to restart'

Of course, this will only work if there's a user logged in, which will typically not be the case with, say, headless servers, in which case you should be able to use traditional UNIX commands without negative consequences.

share|improve this answer
1  
Apple server CLI admin guide (images.apple.com/server/macosx/docs/…) recommand shutdown/restart commands, so it's totaly OK –  radius Aug 16 '10 at 15:11
    
+1 Thanks @radius - updated my post. –  runlevelsix Aug 16 '10 at 15:27
2  
The problem with the shutdown approach is that it kills all running GUI apps, without the option to save the data like with the osascript approach. On a server, this should be OK, but on a workstation, it might be a problem. Still, I use shutdown most of the time, because it is way faster if you have many applications open. –  Sven Aug 16 '10 at 15:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.