1826432 Members
3984 Online
109692 Solutions
New Discussion

ssh does not exit

 
SOLVED
Go to solution
David_246
Trusted Contributor

ssh does not exit

Hi,

I have a script that runs ssh to multiple systems. It does the folowing :
ssh -f -T server1 "/sbin/init.d/logsurfer newstart"

Running it using the -f option at least the prompt gets back, running it without the -f the prompt does not even show up. You have to press + c to get the prompt back. However in both cases the remote command succeeded.
Using the -f option only keeps the processes running in the process table.

Adding an exit to the command also does not work, even adding the exit in the script didn't work.

Anyone a suggestion about how to start a process on the other machine and getting a normal exit ?
I don't like to have many processes running when they already finished their job.

Regs David
@yourservice
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: ssh does not exit

ssh ~^Z -f -T server1 "command"


backgrounds the ssh.

or

~& backgrounds ssh at logout when waiting for frowarded x11 connections.

I think the first suggestion will work.

You could also simply try normal shell scturctures.


ssh .... &

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
David_246
Trusted Contributor

Re: ssh does not exit

Hi SEP,

The problem remains. The process keeps running when using & :
root 24092 1 0 15:58:48 ? 0:00 ssh -f -T server1 /sbin/init.d/logsurfer newstart&

Issue-ing user CTRL+Z I get the following error :
ssh: ~: no address associated with hostname.

I used it pressing +z and + v +z . Both gave the same error.

Any other ones?

Regs David
@yourservice
Massimo Bianchi
Honored Contributor
Solution

Re: ssh does not exit

/sbin/init.d/logsurfer newstart

recall something: the real problem is that logsurfer keeps the stdin open, and do not really release it.


How to trick:

- use the at command to start the logsurfer

- write a wrapper script that starts in bg the logsurfer

- and so on.....

I used the "at" trick with the listener for oracle and worked well.


Massimo



David_246
Trusted Contributor

Re: ssh does not exit

Hi Massimo,

Terrific answer !!!
This is the solution :
>
ssh -f -T server1 "/sbin/init.d/logsurfer newstart"
>
>
Becomes
<
<
ssh -f -T 2n3 "echo \"/sbin/init.d/logsurfer newstart\" | at now"
>
>
@yourservice
David_246
Trusted Contributor

Re: ssh does not exit

hhm,

2n3=server1 :)
@yourservice