Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have the need to run three different bash scripts on three different computers (which is slightly different for each computer) via ssh and then I want to run a command ONLY after all of these scripts have finished.
I was wondering if there was a way in the bash script to tell it to wait until the other scripts have finished successfully before it executes the final line. I know this is usually done by starting the command from the next line, but if we are using ssh to login to a remote machine and then run a script, how would we know if it has completed? So the order of things I want to do are:
ssh into comp1
run startscript1
ssh into comp2
run startscript2
ssh into comp3
run startscript3
<< I want the scripts to all run simultaneously rather than in a specific order >>
wait until all three scripts are finished
run final command
I have setup RSA keys so that I can login without passwords to each machine.. I was wondering I could implement the waiting in the bash script....
Any ideas?
Last edited by Maverick1182; 11-04-2007 at 01:18 PM.
A little add-on: it may be useful to know that you can catch the process ID of the last job running in background by means of $!. This is useful if you want to wait for a specific job only, as in
Wow, thanks for the detailed help everyone. So even somehting as simple as ssh localhost script & with a wait command at the end will wait for all of those processes to finish running before it runs the last command? Linux gets cooler and cooler by the minute! I have to find time to create the script I need but thanks for the templates. It's really helped!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.