0

Currently I am using a for loop in shell script to run several programs one after another. How can I modify the script so that it can run several program at the same time?

#!/usr/bin/env bash
for n in $(seq 0 9)
do
  echo $n
  YAML_PATH_NAME=('./data/setting_'$n'.yaml')
  echo $YAML_PATH_NAME
  python3 program.py --yaml_path $YAML_PATH_NAME
done
jabberwoo
  • 491
  • 6
  • 18
  • 1
    `python3 program.py --yaml_path $YAML_PATH_NAME &` – costaparas Jan 22 '21 at 05:28
  • 1
    FWIW the multiprocessing library is designed to help with this: https://docs.python.org/3/library/multiprocessing.html – effprime Jan 22 '21 at 05:31
  • 1
    Put an '&' on the end of the line where you call Python, that will background that process and move to the next loop iteration without waiting for it to finish. – Z4-tier Jan 22 '21 at 05:31

0 Answers0