Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have remote linux server with paid kvm and very slow 'reboot on request' service. Now when I reboot server with 'sudo reboot' ssh disconnects me within 3-5 seconds, but then server sometimes continue running, I guess, waiting for some rc.d script shutting down. Network still configured, so I can even ping server, but ssh connections can't be established, so, apparently, sshd is down. I can't even dig inside to detect, what is going on during shutdown. So, the question is: how to prevent sshd from stopping during system shutdown? I want sshd running until total system poweroff.

share|improve this question

You don't.

Your operating system needs to stop all processes prior to shutting down. That includes killing off your SSH connections.
The network being "alive" is an artifact of the kernel not having halted/restarted yet - Your ping is being answered by the IP/ICMP stack. Userland could be completely gone and the kernel would continue answering ping.

You can reorder the shutdown scripts so sshd is killed later in the process (look into the documentation for your distribution), however this will just keep the SSH daemon running longer - it won't save your session, which was killed as an independent process (this is why you can stop/start sshd while you're still logged in - the active connections are not "part of the daemon" anymore).
If your system is behaving normally it will have disallowed logins once it began the shutdown process, and you won't be able to log in after your session is killed anyway.

share|improve this answer
well, sshd is placed first on the daemons list, so it starts first, and should be terminated last. Actually, I can not only ping server, but even get response from tomcat which still running to the moment. Webapp shows some errors, because database is already stopped. Which is strange, because db starts before tomcat, and should be stopped after. Anyway, that means that not all processes are stopped, and userland is alive. But I can't look at it to diagnose problem. – Alex Laskin May 2 '12 at 17:08
If you can get responses from Tomcat (something important to tell us in the question) you should be able to SSH in still - or at least connect and get told something to the effect of "The system is going down - you can't log in right now". If you can't then as you've surmised something has gone Horribly Wrong with your shutdown sequence (and you really need to look at the console to see where it got jammed up - once you're kicked out the only debugging tools you have are logs and the console). – voretaq7 May 2 '12 at 18:00

Your Answer


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.