Re: Running local SSH as background process - possible??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a script that I use to do this for my classroom, have 20 primary 
machines, and about 30 other systems, but this is just a single command.
I like using the putty plink command to do the connection.

Here is a sub-set of the script. Define the comand and then run the command 
as a background task to the other system. (Actually, 101 is the machines 
itself), and then 19 other machines in this one. replace real password with 
{password}.

cmd="hostname ; dnf clean metadata ; dnf update -y "
plink  -t  192.168.7.101   -l root -pw {password} "$cmd" & 
plink  -t  192.168.7.201   -l root -pw {password} "$cmd" & 
plink  -t  192.168.7.202   -l root -pw {password} "$cmd" & 
plink  -t  192.168.7.203   -l root -pw {password} "$cmd" & 
plink  -t  192.168.7.204   -l root -pw {password} "$cmd" & 

I have another script that is usefull to monitor the progress, since running the 
3 update scripts works on 54 different systems.

look3 script
while [ -n "`ps -ef | grep plink | grep -v "grep plink"`" ] ; do
clear
ps -ef | grep plink | cut -d- -f 2  | grep -v grep | cut -d\    -f 2 | sort -n | column 
-c 70
ps -ef | grep plink | cut -d- -f 2  | grep -v grep | wc -l
sleep 10
done
echo ""

That displays the IP addresses of the machines that are being processed, 
and the count of home many are currently running. Open another terminal 
window, and run time ./look3

That shows the status and number, and then reports the total time it took to 
complete.

Again, plink is part of putty, so need to install putty if it isn't already.



On 4 Mar 2017 at 9:41, bruce wrote:

From:           	bruce <badouglas@xxxxxxxxx>
Date sent:      	Sat, 4 Mar 2017 09:41:31 -0500
Subject:        	Running local SSH as background process - possible??
To:             	Community support for Fedora users 
<users@xxxxxxxxxxxxxxxxxxxxxxx>
Send reply to:  	Community support for Fedora users 
<users@xxxxxxxxxxxxxxxxxxxxxxx>

> Ok guys,
> 
> I know this isn't strictly "Fed" related, but the group might have suggestions.
> 
> My use case, the process has a number of remote servers. I'd like to
> be able to run a bunch of commands on the remote servers as fast as
> posible. The initial thought was to loop through the different
> IPAddresses, and SSH into each server, to run the commands.
> 
> However, this process was still "sequential" in that each SSH session
> needs to complete, prior to running the next server/ssh command.
> 
> So, my question/need -- is to figure out how to run a ssh as a
> background on the local server. This approach would/should allow the
> process to quickly fire off commands to the remote ipaddresses/servers
> in a much faster/parallel manner.
> 
> sortof:
> 
> foreach iplist as ipaddress
> 
>  ssh user1@ipaddress command &  (assuming that the '&' runs the local
> ssh in the background -- it doesn't!)
> 
> 
> Running "stuff" on the remote can occur in a "Screen" session, which
> would allow the ssh process to fire off the remote cmd, but it still
> doesn't run the local ssh as a "background" process..
> 
> Rick has mentioned/discussed the "Screen" function in past threads.
> 
> Thoughts/comments....
> _______________________________________________
> users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
> To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx


+----------------------------------------------------------+
  Michael D. Setzer II -  Computer Science Instructor      
  Guam Community College  Computer Center                  
  mailto:mikes@xxxxxxxxxxxxxxxx                            
  mailto:msetzerii@xxxxxxxxx
  Guam - Where America's Day Begins                        
  G4L Disk Imaging Project maintainer 
  http://sourceforge.net/projects/g4l/
+----------------------------------------------------------+

http://setiathome.berkeley.edu (Original)
Number of Seti Units Returned:  19,471
Processing time:  32 years, 290 days, 12 hours, 58 minutes
(Total Hours: 287,489)

BOINC@HOME CREDITS
ABC         16613838.513356 | EINSTEIN   129817509.788695
ROSETTA     58150514.717077 | SETI       101559023.269076
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux