LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to parallelize ssh operation? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-parallelize-ssh-operation-4175492768/)

shany 01-27-2014 12:50 PM

how to parallelize ssh operation?
 
Hi All,

I have a script which runs from local site and use ssh to connect to 10 remote servers to execute same script which ofcourse is available in remote servers. The script which i run at remote site takes 20 mins to get complete so my script execution time is 20 * 10 = 200 mins. I'm thinking about running "SSH" operation in background like below, but it throws an error.

nohup ssh remoteserver script-name &

error:-


[1] + Stopped (SIGTTIN) ./script-name &


Is there any way we can parallelize the ssh operation so that i can finish off my script in 10 mins?

joe_2000 01-27-2014 03:18 PM

I think you can get rid of the nohup. Just the & at the end of the line should start the processes in the background. If you want to wait for all processes to finish just put a line below that says "wait" without the quotes.

Code:

ssh remoteserver1 script-name &
ssh remoteserver2 script-name &
ssh remoteserver3 script-name &
wait

EDIT: Just thinking that your error message might be related to something different. Are your scripts trying to read from stdin or write to stdout?

From Wikipedia:
Code:

SIGTTIN and SIGTTOU
    The SIGTTIN and SIGTTOU signals are sent to a process when it attempts to read in or write out respectively from the tty while in the background. Typically, this signal can be received only by processes under job control; daemons do not have controlling terminals and should never receive this signal.


shany 01-27-2014 04:15 PM

Thanks. I have got a way to do it. I need to use -n option to redirect standard input to /dev/null.

joe_2000 01-28-2014 01:26 PM

Quote:

Originally Posted by shany (Post 5106364)
Thanks. I have got a way to do it. I need to use -n option to redirect standard input to /dev/null.

Sounds a bit dangerous... At least you should make sure that you know what your scripts will be doing if they get input from /dev/null, I am assuming that they expect something different...

anomie 01-28-2014 03:04 PM

This problem has been solved with utilities like 'pssh' and 'mussh'.

unSpawn 01-28-2014 06:05 PM

Quote:

Originally Posted by anomie (Post 5106977)
This problem has been solved with utilities like 'pssh' and 'mussh'.

Exactly!


All times are GMT -5. The time now is 08:09 PM.