Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

How to cleanly shut down when things go wrong System
Sometimes I have a situation where I select Shutdown from the OS X menu and the shutdown dialog box will not display.

In fact, none of the other selections from the OS X menu will work either. I'm not sure why this happens, but I was able to find a satisfactory workaround that I have not seen here before. Before when this happened, I was going to the Terminal and typing in shutdown now. Well, that was leaving me with three processes running and a somewhat dysfunctional command prompt. After some experimentation, I just typed in reboot at the Terminal. This seemed to gracefully shut down the remaining three processes, and also gave me a restart back to the Aqua login screen. At the Aqua login screen, I was able to select Shutdown as one of the option buttons and finally do a proper shutdown.

I'm not sure if this is just an odd behavior of Jaguar 10.2.8, or if it's just my system. But I'm not a person that wants to do an entire reinstall of the OS unless I can't boot the machine.

[robg adds: I think there's clearly a system issue at work here, and I would recommend at least re-running the combo updater to 10.2.8, if that's still out there somewhere. I don't recall having any such problems on 10.2.8 myself. The hint here is that the reboot command will get you cleanly back to the login prompt, even when everything else seems to be stuck. I don't think we've covered this one here before, but if someone proves me wrong, just let me know and I'll remove this one...]
    •    
  • Currently 2.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[15,996 views]  

How to cleanly shut down when things go wrong | 19 comments | Create New Account
Click here to return to the 'How to cleanly shut down when things go wrong' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Or shutdown -r now
Authored by: googoo on Sep 10, '04 10:42:55AM
According to the shutdown man page, the shutdown command with no options brings the system down to single user mode but does not reboot. If you use the -r option, it does execute the reboot command. The main difference between using shutdown -r and reboot is that shutdown requires a time (i.e., shutdown -r now) and will warn all logged on users of the impending shutdown. (I realize that this is not important if you just want to reboot your Mac immediately.)

-Mark



[ Reply to This | # ]
How to cleanly shut down when things go wrong
Authored by: Archange11 on Sep 10, '04 10:52:26AM

I have version 10.3.5 and I can't shutdown either. I tried the terminal commands above, and this is what I get:

Last login: Fri Sep 10 10:45:26 on ttyp1
Welcome to Darwin!
xx-xxxx-Computer:~ xxxx $ shutdown now
shutdown: NOT super-user
xx-xxxx-Computer:~ xxxx$ shutdown -r now
shutdown: NOT super-user
xx-xxxx-Computer:~ xxxx $ reboot
reboot: Operation not permitted
xx-xxxx-Computer:~ xxxx $

What is a super-user? I am in the administrator account and I am the only account on the computer. I shut down processes in the activity monitor that I knew were programs I didn't need. When I did a hard reboot and went back to the login window, I was able to shutdown and restart there.



[ Reply to This | # ]
Superuser
Authored by: googoo on Sep 10, '04 11:41:51AM
Superuser is UNIX jargon for root user. In other words, you must execute these commands with administrative privileges. You do that by prefixing a sudo command before the command you would like to execute. For example,

sudo reboot

You will be asked for your password, and (as long as you are an administrative user) the command will execute as root. Enter man sudo for much more info.

-Mark



[ Reply to This | # ]
How to cleanly shut down when things go wrong
Authored by: Anonymous on Sep 10, '04 10:52:38AM
shutdown now was doing exactly what it was supposed to do, but not what you wanted (i.e., turn the computer off). From man shutdown:

A terminate signal is then sent to init to bring the system down to single-user state (depending on above options).

What you needed to do is shutdown -h now. The '-h' switch causes shutdown to exec a halt (see also '-r' for a reboot).

If you do a man reboot you will see the following "guidance"

Normally, the shutdown(8) utility is used when the system needs to be halted or restarted, giving users advance warning of their impending doom and cleanly terminating specific programs.

The implication is that shutdown is preferred to reboot (or halt) since it notifies logged in users. If you are the only one using your machine then I guess either is fine.

Remember, the man pages are your friends...

[ Reply to This | # ]

How to cleanly shut down when things go wrong
Authored by: aqsalter on Sep 11, '04 03:55:34AM
Is there an easy way to get back up from single user mode? If so you could just do a shutdown now and then excute the command that would bring it back up again.... Viola! Quick reboot! ;)

[ Reply to This | # ]
How to cleanly shut down when things go wrong
Authored by: lamon on Sep 10, '04 10:53:33AM

And if you want to halt (turn off) the computer, from my old unix days, it's

shutdown -h now



[ Reply to This | # ]
How to cleanly shut down when things go wrong
Authored by: audiluv on Sep 10, '04 01:01:18PM

The reboot command tells the kernel to sync the file system and go back to the bootstrap process. This is not a clean shutdown. Anything that has open files or caches that have not properly been written or flushed stands a chance of corruption.

A clean shutdown can be invoked with the shutdown command. This goes through the inittab and shuts down services properly. However, shutdown does not alway work if there are hung processes or zombied threads. Killing the process with the kill (kill -9 pid) command usually works on hung processes. If not sometimes kill -HUP pid will make the process behave (long enough to kill it) or exit.

If all else fails using the reboot command is better than hitting the power or reset button. The power and reset button not only can cause file system corruption but can damage hardware.


---
"If you insist on getting credit for the work you do, you'll never get far in life. Don't confuse yourself with the idea of getting credit" - Colonel John Richa



[ Reply to This | # ]
kill -9 overkill
Authored by: sjk on Sep 10, '04 04:47:04PM
Killing the process with the kill (kill -9 pid) command usually works on hung processes. If not sometimes kill -HUP pid will make the process behave (long enough to kill it) or exit.

kill -KILL (aka "-9") is best saved as the last resort when other signals have failed to kill a process. And kill -HUP won't kill a process that kill -KILL didn't, at least not on any Unix-based systems I've used.

kill -9 is often misunderstood and misused, as explained in places like:

kill -9
Useless use of kill -9

And MacOSXHints could consider publishing this as a separate hint to help slow the propagation of disinformation in the OS X community. :-)

[ Reply to This | # ]
Anyone else have a clue about this one?
Authored by: azraq27 on Sep 10, '04 01:15:19PM

I'm coming from Unix, so I knew about the shutdown/reboot commands, but I wonder if there is a cleaner way of doing this. I run into this problem myself constantly. I try killing all the processes I can (and usually end up just crashing the computer), but have never gotten anything to work.

Does anyone know what is causing this, if anything beyond just a generic hung process? Does anyone have any tips on how to find the process that is hung?



[ Reply to This | # ]
Anyone else have a clue about this one?
Authored by: ber on Sep 10, '04 02:51:29PM

I've found 80% of the time my machine hangs (spinning beach ball) I can recover by killing coredservicesd. That usually let's me save files and quit applications (avoiding messed up preferences). Then I do a Restart...

brian



[ Reply to This | # ]
Anyone else have a clue about this one?
Authored by: audiluv on Sep 10, '04 04:14:53PM

Often the problem process is hogging the cpu. You can use top to find out which one.

---
"If you insist on getting credit for the work you do, you'll never get far in life. Don't confuse yourself with the idea of getting credit" - Colonel John Richa



[ Reply to This | # ]
Anyone else have a clue about this one?
Authored by: johnsawyercjs on Sep 14, '04 03:45:26AM

I've been dealing with this failure of OS X to sometimes shut down/restart/log out fairly frequently; sometimes the problem disappears, only to return later. I have several volumes running on my B&W G3, with different versions of OS X on each one (10.2.8, 10.3.3, 10.3.5), and currently the version that has this problem is 10.3.3. I've done a lot of searching for answers, on Apple Discussions, Macfixit, etc., and several causes and fixes have been found, but none work for me. Anyway, some typical causes are any of the Norton software (Norton Utils, Norton Antivirus--disable all of this and see what happens); Classic still running; network volumes still mounted; some dumb daemon; etc. For some people, reinstalling the OS X Combo updater helps, and for others, repairing the hard drive's directory and/or permissions fixes this. Not for me. I've determined that it's nothing in the Users folder, nor in /Library, which leaves /System, and the invisible files. Next step is to try the experiment where I install a clean OS 10.3.3 on another volume, then start moving its files to the problem volume until the problem volume once again can restart/shut down/log out--the last file I move over that fixes the problem, will be the culprit (if it turns out to be that "easy").



[ Reply to This | # ]
restart or logout
Authored by: TigerKR on Sep 10, '04 11:58:14PM

If you want to restart your machine gracefully, as other's have said, try "sudo shutdown -r now"

But if your graphical interface has frozen, and you're still able to ssh (log in via the terminal) from another computer, try "sudo killall loginwindow" which should bring you back to the Mac OS X Login screen.

If you get a kernel panic, or these solutions don't work, I'd try to disconnect all peripherals (kernel panics are almost always caused by hardware), and for some people booting into open firmware, and flashing the parameter settings helps (startup the computer holding down Option-Apple-P-R and then at the prompt, type "reset-nvram" and "reset-all").



[ Reply to This | # ]
kill -9 is not overkill in the context of this thread
Authored by: audiluv on Sep 11, '04 09:02:31AM

In the context of this thread kill -9 is very useful rather than just rebooting a system, which basically is a kill -9 on the whole system. If you take my message out of the context of this thread I agree you don't want to go around using it because of the likelihood of data corruption.

In my more than a decade of experience managing hundereds of Unix systems kill -HUP can get rid of zombied process, not all the time but it is something to try.

Disinformation is often information taken out of context. :-)

---
"If you insist on getting credit for the work you do, you'll never get far in life. Don't confuse yourself with the idea of getting credit" - Colonel John Richa



[ Reply to This | # ]
How to cleanly shut down when things go wrong
Authored by: paineless on Sep 12, '04 03:13:07PM

The failure of the shutdown command in the GUI is a problem I've seen repeatedly, but it seems to be hardware specific. I have had several revisions of the OS on a 450Mhz G4, all the way up to 10.3.4 and under every one, I have this problem. But very rarely does it occur on any other system I have run. Sometimes, but not always, quitting the Classic environment and ejecting all network volumes before selecting the Shutdown command from the menu avoids the problem, but not doing these two things almost always causes the command to fail, necessitating a trip to the terminal.



[ Reply to This | # ]
How to cleanly shut down when things go wrong
Authored by: adams4 on Sep 13, '04 09:11:02AM

The deal is this: when you use the shutdown command, you're executing certain scripts before the machine turns off (shutdown -h) or restarts (shutdown -r). When you execute reboot, you say, "please end all jobs if you can, kill what you can't, log this to the system log, write any cache back to disk, then restart cleanly." You can also use reboot -n to not flush the cache or reboot -q to reboot "quickly" (i.e., ungracefully). Thus executing reboot -nq is the equivalent of pressing the restart button.

If you just want to shutdown the machine, but you've got problematic jobs, then try using halt. This will terminate "good" jobs as above, kill "bad" jobs, flush cache, then power off (instead of restart as reboot does). Similar to reboot, you can halt -n, halt -q, or halt -nq to not flush cache, halt "quick," or just power off without doing anything (the equivalent of holding the power button to shut the machine off).

One more thing: these commands must all be executed using either sudo or by being root (you either logged in that way from the login screen or used su).

---
Adam Spector.

[ Reply to This | # ]

How to cleanly shut down when things go wrong
Authored by: alys on Sep 14, '04 05:27:48AM

A Unix sysadmin of my acquaintance says that if your system's in trouble, it's often worth waiting a while to see if it recovers. Up to fifteen minutes is probably sufficient; if hung processes haven't recovered by then, they probably won't. In his words, "If there's a particular process that's causing problems, then it's possible that it might be waiting for an interrupt of some sort", which might occur after several minutes. He's seen cases where a kill -9 hasn't worked at first, but then several minutes later it has taken effect, and a shutdown has not been necessary.



[ Reply to This | # ]
How to cleanly shut down when things go wrong
Authored by: mackritter on Sep 15, '04 03:38:02AM

One of the easiest ways I have found since you can get to the Terminal. Is to top and find the process id for "loginwindo" and kill that process. That will exit you out of your user to the main log-in window from there you can reboot or shutdown.
This works in 10.3 and up. Un-sure about older version of X

---
Artificial intelligence is no match for natural stupidity!



[ Reply to This | # ]
How to cleanly shut down when things go wrong
Authored by: xevious70 on Feb 07, '05 03:30:28PM
Greetings: I'm really glad to have found this site, and especially this thread. I was experiencing a no-shutdown / restart problem this morning (G4 800MHz / OS 10.3.7) and it was getting pretty annoying.

I'd never touched the Terminal feature of my G4 (and never wanted to, since I don't know how to use it) - but after reading this thread I had the confidence to go to Terminal and key in
sudo shutdown -r now
to gracefully restart...and it did.

Heh - I'll admit, that was the first time I'd typed in code since my Basic Computer Programming class in 1983, when we used TRS-80s. But it worked. So thanks a bunch.

Yours,
X70

[ Reply to This | # ]