0

So, I just wanted to know So, I just wanted to know how 2 or more scripts can be run in parallel. I searched a few places and saw mentions of using the '&' in between the various scripts I have but I would not be sure. So, can anyone provide me ideas how it can be possible or various ways I can initiate the process?

1

2 Answers 2

1

Simplest way :

#!/bin/sh

/usr/bin/my-process-1 --args1 &
/usr/bin/my-process-2 --args2 &
/usr/bin/my-process-3 --args3 &

wait
echo all processes complete

Source : https://www.codeword.xyz/2015/09/02/three-ways-to-script-processes-in-parallel/

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

2 Comments

So only using the & between the scripts is the way to do it? Thanks
It's the easiest way you got to do it, but you can check in the link for more ways to do it, if the & is a problem !
1

Using & that put the application in the background.

from the man bash.

If a command is terminated by the control operator &, the shell executes the command in the background in a subshell. The shell does not wait for the command to finish, and the return status is 0.

For example.

Running shell script with shell script you can do like this,

#!/bin/bash
sh ./script1 &
sh ./script2 &

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.