Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6560881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:31:06+00:00 2026-05-25T13:31:06+00:00

Hi all, I am trying to run a server on one host, and have

  • 0

Hi all,

I am trying to run a server on one host, and have 3 clients located on 3 different hosts run at the same time (in the background).

I made a bash script to do that. The problem is that the script currently does not wait for the client to finish: it ssh on each host sequentially. I would like to have the 3 hosts run in parallel please.

Here is the code:

#!/bin/bash
i="0"
dir="~/bin/"

while [ $i -lt 3 ]
do
  let number=10+$i
  ssh sshost$number 'cd $dir && java Main &' 
  let i=$i+1
done

I am trying to ssh to 3 different hosts (number gets changed on each iteration), then go to the directory and type java Main. My only problem is that it won’t do it in parallel, and I can’t figure out how to fix it.

I would appreciate any help.

Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:31:07+00:00Added an answer on May 25, 2026 at 1:31 pm

    Make the ssh command to run in background:

    ssh sshost$number 'cd $dir && java Main &' &
    

    You can call wait outside the while loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run MonoDevelop on apple. I have instaled all the necessary SDK
I am trying to run indent -kr -i8 on all files in my current
I'm trying to run a bash script when my EC2 instances start up. All
I set up all my certificates and keys today and am trying to run
I have been trying all afternoon to get the jQuery Sifr Plugin ( http://jquery.thewikies.com/sifr/
I have been trying all day to get some data properly formatted in a
I'm trying to install redmine on a Centos server. I already have PHP and
I'm running SQL Server 2008, and trying to run some queries on some poorly
I'm setting up a new Ubuntu server running nginx, and I'm trying to run
I am trying to run a script on a Debian server that uses module

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.