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 01-27-2014, 01:50 PM   #1
shany
LQ Newbie
 
Registered: Oct 2012
Posts: 5

Rep: Reputation: Disabled
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?
 
Old 01-27-2014, 04:18 PM   #2
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Arch, Debian
Posts: 859

Rep: Reputation: 245Reputation: 245Reputation: 245
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.

Last edited by joe_2000; 01-27-2014 at 04:24 PM.
 
Old 01-27-2014, 05:15 PM   #3
shany
LQ Newbie
 
Registered: Oct 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks. I have got a way to do it. I need to use -n option to redirect standard input to /dev/null.
 
Old 01-28-2014, 02:26 PM   #4
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Arch, Debian
Posts: 859

Rep: Reputation: 245Reputation: 245Reputation: 245
Quote:
Originally Posted by shany View Post
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...
 
Old 01-28-2014, 04:04 PM   #5
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
This problem has been solved with utilities like 'pssh' and 'mussh'.
 
Old 01-28-2014, 07:05 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
Quote:
Originally Posted by anomie View Post
This problem has been solved with utilities like 'pssh' and 'mussh'.
Exactly!
 
  


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
[SOLVED] Parallelize a for loop Philosopher Programming 11 05-24-2013 08:18 AM
CentOS SSH operation timed out nino90 Linux - Networking 2 01-28-2009 01:22 AM
LXer: Parallelize Applications for Faster Linux Booting LXer Syndicated Linux News 0 06-17-2008 07:40 PM
LXer: Parallelize Application for Faster Linux Booting LXer Syndicated Linux News 0 03-13-2007 02:31 PM
How to restrict the ssh operation for one user fidelis Linux - Security 2 09-13-2004 03:37 AM

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

All times are GMT -5. The time now is 11:51 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration