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?
-
Welcome to Stack Overflow - nice to have you. Please read How do I ask a good question? and How to create a Minimal, Complete, and Verifiable example to help keeping Stack Overflows content on the highest possible level and increase your chances getting an appropriate answer.sebast26– sebast262018-01-24 14:52:38 +00:00Commented Jan 24, 2018 at 14:52
Add a comment
|
2 Answers
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/
2 Comments
jake elias
So only using the & between the scripts is the way to do it? Thanks
Alexandre Beaudet
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 !
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 &