Bash – Run Multiple Scripts in Parallel Instead of Sequence

background-processbashparallelismshell-script

Suppose that I have three (or more) bash scripts: script1.sh, script2.sh, and script3.sh. I would like to call all three of these scripts and run them in parallel. One way to do this is to just execute the following commands:

nohup bash script1.sh &
nohup bash script2.sh &
nohup bash script3.sh &

(In general, the scripts may take several hours or days to finish, so I would like to use nohup so that they continue running even if my console closes.)

But, is there any way to execute those three commands in parallel with a single call?

I was thinking something like

nohup bash script{1..3}.sh &

but this appears to execute script1.sh, script2.sh, and script3.sh in sequence, not in parallel.

Best Answer

for((i=1;i<100;i++)); do nohup bash script${i}.sh & done
Related Question