I have the following code that submits several subjobs withing a docker container:
#!/bin/bash for file in "all files of a given type"; do docker exec -itd "docker container" "command to be executed within docker container" & done pidlist=$(pgrep -f "command to be executed within docker container") for pid in $pidlist; do echo $pid wait $pid done
My goal is to have the script wait to exit until all the subjobs are done. I need this since this script is part of a larger script containing other commands and scripts.
However, the PIDs that I get are not the same as when I use top at the terminal to locate the subjobs and so, the script exits after it has submitted all the subjobs.