Please use multiprocessing and subprocess. When using a custom shell script, if it is not in the PATH then use the full path to the script. If your script is in the same folder as the python script, please use ./script.sh as your command.
Also ensure that there is exec permission for the script that you are running
from multiprocessing import Pool
import subprocess
def run_script(input):
(command,arg_str)=input
print("Starting command :{} with argument {}".format(command, arg_str))
result = subprocess.call(command+" "+arg_str, shell=True)
print("Completed command :{} with argument {}".format(command, arg_str))
return result
with Pool(5) as p: # choose appropriate level of parallelism
# choose appropriate command and argument, can be fetched from sys.argv if needed
exit_codes = p.map(run_script, [('echo','hello1'), ('echo','hello2')])
print("Exit codes : {}".format(exit_codes))
You could use the exit codes to verify the completion status.
Sample output :
Starting command :echo with argument hello1
Starting command :echo with argument hello2
hello1
hello2
Completed command :echo with argument hello1
Completed command :echo with argument hello2
Exit codes : [0, 0]
Another way to do this (without python) would be to use GNU Parallel. The below command does the same thing that the above python script does.
parallel -k echo ::: 'hello1' 'hello2'
tool1 $1 & tool2 $1 & tool3 $1 & tool4 $1 & tool5 $1(basically add&at the end of each line).