Start multiple Linux clients from script

Questions and Answers : Unix/Linux : Start multiple Linux clients from script
Message board moderation

To post messages, you must log in.

AuthorMessage
ross

Send message
Joined: 26 Aug 03
Posts: 4
Credit: 4,593,158
RAC: 0
South Africa
Message 226441 - Posted: 5 Jan 2006, 18:19:43 UTC

Hi
I am a relative Linux newbie, and have several linux boxes to learn on. I want to stop and start the client on demand, and have been ssh'ing in to start them individually. I would like to start the program on all 5 boxes with a script. I have setup ssh to use keys rather than a password so the script logs in automatically without a password prompt, and tried a simple script:
ssh <client1 IP> <command>
ssh <client2 IP> <command> etc

The problem is that the script starts up the first client but the first line doesn't complete so the 2nd client isn't started. I have been cheating by running the same script 5 times as after the error message client already running it moves onto the next line. I would like the script to open each client in a seperate terminal window so I can keep tabs on what the machines are up to. Any scripting advice would be welcome.

Thanks
Ross
ID: 226441 · Report as offensive
Dotsch
Volunteer tester
Avatar

Send message
Joined: 9 Jun 99
Posts: 2422
Credit: 919,393
RAC: 0
Germany
Message 226617 - Posted: 6 Jan 2006, 0:22:59 UTC
Last modified: 6 Jan 2006, 0:24:18 UTC

You can start the ssh with the -f option, and all start the boinc client in the background.

A short example, for the thing you would do. It starts command on client1 and client2 and logs the output to $LOGFILE ($LOGFILE is the path and filename where the outputs of <command> should be logged :
#!/bin/sh
ssh  -f "<client1 IP> <command> > $LOGFILE 2>&1 " &
ssh  -f "<client1 IP> <command> > $LOGFILE 2>&1 " &


ID: 226617 · Report as offensive

Questions and Answers : Unix/Linux : Start multiple Linux clients from script


 
©2025 University of California
 
SETI@home and Astropulse are funded by grants from the National Science Foundation, NASA, and donations from SETI@home volunteers. AstroPulse is funded in part by the NSF through grant AST-0307956.