LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-18-2018, 11:24 PM   #1
rnimgaok
LQ Newbie
 
Registered: Jul 2018
Posts: 1

Rep: Reputation: Disabled
Unhappy ssh port 22: Connection refused caused by shell script launched in infinite loop


Hi ,

I was trying to execute a shell script(abc.sh) which called another shell script(execute.sh) in setsid and moved it to background . Something like this :

setsid ./execute.sh > $USER_ID-execute.out 2>&1 & >> log.out
This was called from abc.sh

Somehow the above execute.sh was launched infinitely , and the processes kept on increasing like :

30894 ? Ss 0:00 /bin/bash ./execute.sh
30899 ? Ss 0:00 \_ /bin/bash ./execute.sh
30904 ? Ss 0:00 \_ /bin/bash ./execute.sh
30909 ? Ss 0:00 \_ /bin/bash ./execute.sh
30914 ? Ss 0:00 \_ /bin/bash ./execute.sh
30919 ? Ss 0:00 \_ /bin/bash ./execute.sh
30924 ? Ss 0:00 \_ /bin/bash ./execute.sh
30929 ? Ss 0:00 \_ /bin/bash ./execute.sh
30934 ? Ss 0:00 \_ /bin/bash ./execute.sh
30939 ? Ss 0:00 \_ /bin/bash ./execute.sh
30944 ? Ss 0:00 \_ /bin/bash ./execute.sh
30949 ? Ss 0:00 \_ /bin/bash ./execute.sh
30954 ? Ss 0:00 \_ /bin/bash ./execute.sh
30959 ? Ss 0:00 \_ /bin/bash ./execute.sh
30964 ? Ss 0:00 \_ /bin/bash ./execute.sh
30969 ? Ss 0:00 \_ /bin/bash ./execute.sh
30974 ? Ss 0:00 \_ /bin/bash ./execute.sh
30979 ? Ss 0:00 \_ /bin/bash ./execute.sh
30984 ? Ss 0:00 \_ /bin/bash ./execute.sh
30989 ? Ss 0:00 \_ /bin/bash ./execute.sh
30994 ? Ss 0:00 \_ /bin/bash ./execute.sh
30999 ? Ss 0:00 \_ /bin/bash ./execute.
31004 ? Ss 0:00 \_ /bin/bash ./execute
31009 ? Ss 0:00 \_ /bin/bash ./exe
31014 ? Ss 0:00 \_ /bin/bash .
31019 ? Ss 0:00 \_ /bin/ba
31024 ? Ss 0:00 \_ /bi
31029 ? Ss 0:00 \_
31034 ? Ss 0:00


Eventually I lost connection to that linux box and I got below message :

Connection to vm-abc closed.

And now when I try to ssh the box I get message as :
ssh: connect to host vm-abc port 22: Connection refused

So I need solutions for 2 problems :
1. Why did the script went to infinite loop ?
2. What can be done now to get the linux box back ?

I am able to ping this linux box .

Any pointers would help , TIA.

Last edited by rnimgaok; 07-18-2018 at 11:25 PM.
 
Old 07-19-2018, 12:33 AM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
How could anyone here know the answer if we can't see the scripts. I would say you are probably making a recursive call from one script to the other. Just wait a while to get back in, maybe a day or so.
 
Old 07-19-2018, 10:37 AM   #3
DaneM
Member
 
Registered: Oct 2003
Location: Chico, CA, USA
Distribution: Linux Mint
Posts: 881

Rep: Reputation: 130Reputation: 130
1. The script has a recursive loop in it, as AwesomeMachine says. Please post the script, so we can help debug it.

2. Reboot the Linux machine. If you have set that script to start at boot, you will need to do one of the following:

2a. If the machine is a VM/cloud instance, shut it down and detach the boot volume. Attach it to another VM. Boot the other VM. Mount the detached volume, edit the startup configuration to stop the script from starting at boot. Unmount and detach the volume from the other VM. Re-attach it to the original VM. Boot.

2b. If the machine is on bare metal (physical computer), shut it down and boot up with a live USB or CD. Mount the hard drive, edit the startup configuration to stop the script from starting at boot. Unmount the hard drive. Reboot.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error- Nmap shell script goes in infinite loop sknsk Programming 1 05-25-2017 07:37 AM
SSH connection refused port 22 XDaniel Linux - Networking 3 03-06-2011 10:53 PM
Bash script - Infinite loop caused by a logical OR operator skuzye Programming 9 02-04-2009 01:31 PM
ssh: connection refused, port 22 Roko Linux - Networking 5 12-01-2008 05:12 AM
SSH port...Connection....refused?? Miyamoto Mandriva 6 08-26-2003 04:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration