0

I currently have a Bash Script ("Bash Script 1") that executes a PHP file. I would like to have a Bash script that can launch multiple instances of "Bash Script 1" and let them run at the same time.

Is this possible and how might I go about this?

Any thoughts or comments would be greatly appreciated.

2 Answers 2

7

Run them in the background, just like you would in an interactive shell.

command1 &
command2 &
command3 &
wait # Wait for all background commands to finish

The commands can be just about anything, not just other bash scripts.

Sign up to request clarification or add additional context in comments.

Comments

1

If you want to repeat the same command:

N=10 # number of repetitions
for i in $(seq $N)
do
    bash_script_1&
done

2 Comments

+1, though there's no real need to call out to seq; you might as well use built-in Bash features, like for ((i = 0 ; i < 10 ; ++i)) or for i in {1..10}.
Maybe, but unfortunately {1..$N} does not work if you want to use a variable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.