Methods for shutting down or restarting your Mac
This may sound like a rather trivial issue, but shutting down or restarting your Mac can be a problem at times. Knowing various ways to shut down or restart your Mac can help prevent you from having to take drastic measures in the event of software hangs and crashes.
Every now and then OS X will hang on a process, or experience some other behavior that prevents the system from functioning properly. When this happens, usually a restart can clear the problem if you have no other way of tackling the hang directly.
There are several ways to shut down or restart your system, some of which are better in some circumstances than others, depending on the state of your system.
The Apple menu
Use of the Apple menu is the standard way to shut down a Mac running OS X. The use of this function closes applications safely, providing pauses in the shutdown process while documents are closed. In most occasions this will work to shut down or restart the system, but every now and then the system menus will not respond, leaving this option unavailable.
The shutdown window
The shutdown window is invoked by pressing the power button on older Macs' keyboards, but can be done on newer Macs by pressing Control-Eject or pressing the power button once (for laptops). From here, you can click the options to sleep, shutdown, or restart your Mac. These invoked shutdown and restart commands perform similarly to the ones from the Apple menu, resulting in the same shutdown and restart behaviors that pause for processes to quit properly before continuing with the shutdown.
Hot keys
In addition to the shutdown menu hot key, there are some additional "Control-Eject" based hot keys that can be used to immediately restart or shutdown the computer without first using the menu:
The Terminal
A more raw option for shutting down the computer is to use commands in the Terminal. The various options are the following:
These commands will send termination and halt signals to running processes, and then power off or reset the hardware. This is a more crude approach to halting the system because it does not give running processes the time to quit normally and save settings or unsaved documents. Most processes are built to handle this kind of force-quitting, but it can be hard on the system if done repeatedly. The "-q" flag for the halt and reboot commands offer an even more crude way of shutting down the system, by preventing logging of the shutdown event and processes are quit as quickly and ungracefully as possible.
The Terminal part 2: Remote log-in
Many times people will find their whole system seems to be hung up and not responding. They cannot click any elements on the screen, or open any programs (including the Terminal). This prevents them from running any sort of shutdown commands that may prevent the use of a hard reset. To use remote log-in, you will need to enable it in the "Sharing" system preferences and make note of the computer's IP address. Then from another computer on the same network, run the following command in the terminal to log in to your computer:
This will start a remote log-in session after you enter your password at the prompt, and will let you run commands on your system as if you were running the Terminal application locally. From here, you can issue the "shutdown", "halt", and "reboot" commands when the system's interface is frozen. This usually will be successful at rebooting the system.
The last resort
If nothing works (such as you cannot log-in remotely and nothing is responding on the screen), then the last resort is to hard-reset the system. This is done by holding the power button down until the system shuts off, which should take only a few seconds. There are a couple of precautions that should be observed when doing a hard reset, which are:
- Only do it when the hard drive is not being accessed.
If the hard drive is being accessed and you power off the system, you can damage the heads or platters. As a result, press your ear against the computer and if you hear the drive chattering and reading then do not power off the system. Wait until the drive stops making noises before you hard-reset the system. Granted sometimes this is not possible, but it should be attempted. - Check system for errors.
After performing the hard-reset, immediately boot up into safe mode and run diagnostics to ensure the system is functioning normally. Hold the "Shift" key at startup to get into Safe mode, which will run disk checks and other maintenance scripts. Then use Disk Utility to check the hard drive for errors and run a permissions fix. These are usually all that's required to check the system, but if you have other utility programs you might run them as well.
Finally, there are rare occasions where the system management controller or other low-level hardware is malfunctioning and the power button will not work to reset the computer. In these instances, you will need to cut power to the system by physically unplugging it (for laptops, remove the battery first and then unplug the power supply). It's the type of thing that makes computer technicians cringe, but is sometimes the only option. Be sure the hard drive is silent before doing this, and before rebooting be sure to reset the system management controller, followed by a PRAM reset, and then booting into Safe mode and running system diagnostics.
To reset the System Management Controller, follow the instructions in these Apple knowledgebase articles:
- Portables: http://support.apple.com/kb/HT1411
- Mac Pro: http://support.apple.com/kb/HT1806
- Mac Mini and iMac: http://support.apple.com/kb/HT1543
After the SMC is reset, power on the system and hold the Option-Command-P-R keys all at once, allowing the computer to reset and chime a couple of times before releasing the keys and immediately pressing the Shift key to get the system to boot into Safe mode. From here, run diagnostics and reboot the system accordingly and hopefully everything is working as it should.
UPDATE: The terminal commands may require the use of "sudo" before them, such as "sudo shutdown -h now" to run the command as root.
Resources
Option Command Esc shows the Force Quit window, but nothing to quit is shown. Control Eject shows the restart-shutdown window, yet it does not work. The only way ou of it is to press the power button a few seconds to shut down. Both on PowerPC and Intel Macs.
The issue hits 1 in 10 times for PowerPC and 1 in 20 for Intel, or so.
How to fix it? It is frustrating. Mac OS X 10.5.7 and previous versions.
That sounds like a hang of sorts, and can probably best be tackled by logging in remotely and issuing the shutdown commands in the terminal.
Perhaps you should be at Apple > Support > Communities.
Sign in so you can enter comments and questions; otherwise, you can only read what others have contributed - and that may provide all the answers you need.
I've seen this same behavior recently on an old iMac G4 and a new Mac Mini, both running 10.5.7 that were updated using the Combo updater. I also saw it happen on an early 2008 20" iMac running 10.5.6 a couple months ago, which was also updated using the Combo updater. And on each, the problem happened with no third party software installed. When it happens, the Finder and Dock quit, and then something halts the restart-shutdown-logout procedure at that point. Nothing is written to the logs. I wrote a post about this over in the Apple Community forums three weeks ago, and no one has yet posted a fix that works, or an explanation of how and why it's happening.
I also had this problem, but I found a fix. I don't know if it will work for you guys though. I tried to find PA Geographer's post at the Apple Community support forums, but I could not find it. Can you please post this solution there as well?
Anyway, I fiddle around a bit with the terminal and found that the shutdown command could not be used, or rather using
'sudo shutdown -r now'
resulted in an error message:
"shutdown: /sbin/reboot: Exec format error"
So, I thought I'd have a look at the /sbin directory, using
ls -alF /sbin/
I found that the /sbin/reboot and /sbin/halt binaries were totally screwed, looking like:
-r-xr-xr-x 16509 root wheel 0 Mar 9 19:40 reboot*
-r-xr-xr-x 16509 root wheel 0 Mar 9 19:40 halt*
So, my solution was to simply copy those commands back from the installation DVD. Just put hte DVD into the mac, then make a backup of the commands just in case.
sudo mv /sbin/halt /sbin/halt.bak
sudo mv /sbin/reboot /sbin/reboot.bak
Then copy the new ones from the DVD:
sudo cp /Volumes/Mac\ OS\ X\ Install\ DVD/sbin/halt /sbin/
sudo cp /Volumes/Mac\ OS\ X\ Install\ DVD/sbin/reboot /sbin/
Now, you can reboot and shutdown again, using the terminal, key-combo, the menus or whatever. Issue solved!
And, oh sorry I forgot to mention. This was on a G4 mac mini running Tiger 10.4.11, what broke the commands I have no clue about since i have a lot of third party apps installed. But seriously I belive that it was somekind of apple update since third party apps hardly fiddles around with the basic unix system installed. I noticed the problem first after the latest Safari (4.0.2) and iTunes (8.2.1) updates but It seems strange if it is related to those updates.
Good luck!
<code>osascript -e 'tell app "system events" to shut down'</code>
This is useful when you ssh into another computer, and want to attempt a "less crude" shutdown. You can still do the <code>reboot</code> command if the first command did not work. Although I usually do <code>sudo reboot</code>
<code>osascript -e 'tell app "system events" to sleep'
osascript -e 'tell app "system events" to restart'
osascript -e 'tell app "system events" to log out' </code>
are similar commands.
You can do this by AppleScript too. But I looked up the Applescript web page and its not there any more!
I am also running 10.5.7 (haven't posted in awhile and just realized I forgot to change my sig)
- by AdamS4 July 1, 2009 10:09 AM PDT
- <code>shutdown</code> or <code>halt</code> must be run in Terminal as a super-user. E.g., to shutdown the computer now, a user would type
- Like this Reply to this comment
-
(11 Comments)<code>sudo shutdown -h now</code>
Note that there are other options for <code>shutdown</code> and for <code>halt</code>. For instance, if you really needed to shutdown the machine in a hurry, you might use
<code>halt -nq</code> (run as a super-user, of course)
The <code>-n</code> part means "don't flush the file system cache."
Between the two, use <code>shutdown</code>, because that runs particular scripts before the machine actually shuts down. It also has the ability to alert users, to give them time to save whatever work they might be doing (e.g., users who are logged in with <code>ssh</code>). For more info, in Terminal, type <code>man shutdown</code> to get a complete description.