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

At one of our servers, by mistake I ran into shell/ssh the code:

while `yes `; do ls; done;

And now I want to conenct back to it but it's still hung. What can I do?

share|improve this question
    
You say "it's still hung", but you don't give specifics. Is it that shell session that's hung? Can you ssh in again? Is there an ssh banner when you telnet to port 22? The recipe you've posted above should lock up a session tight but it doesn't grow with time like a fork bomb, so hopefully it shouldn't be able to take the machine down; it should just make it really slow. –  MadHatter Mar 3 '12 at 10:38
    
Sorry if i didnt make it clear. I thought at first it was the SSH session, so I tried to opened another from a different machine. But the whole server was irresponsibly hung. Even CRON entries were not running. –  rahmanisback Mar 3 '12 at 22:39

2 Answers 2

up vote 3 down vote accepted

If your system is not responding at all, I don't think you can do anything except hardware reset/reboot.

In a multi-core architecture, only one CPU core should be busy 100% usage. Other cores should be available. So, you should be able to connect to your server using another shell.

share|improve this answer
    
Thanks. It was taking so long but I did ssh root@serveraddress "reboot;" after around 30 minutes it responded and rebooted. –  rahmanisback Mar 3 '12 at 22:43

Well, if you still have a shell opened or you can open a new shell, you can kill the process by looking for it with ps aux and grepping for the name of the shell script. As MadHatter suggested you should use kill -9 to kill the process.

If you can't connect to it through SSH, you will have to go there to get physical access I'm afraid (or something like remote hands) and see if it's salvageable or not. If not you will have to pull the plug.

Maybe if it starts using enough memory or resources, OOM killer will come buy and kill it, but there might be other stuff breaking then.

share|improve this answer
1  
I was just about to write pretty much the same thing, except that I tested it, and it only wedges the shell from which you run it. You should still be fine to ssh in and kill -9 the PID of the offending shell (kill -15 doesn't seem to cut it). –  MadHatter Mar 3 '12 at 10:42

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.