I bash you can easily run the script part in another process just by using '(' and ')'. If you add & , the parent process will not wait for the child. So you are actually using ( command1; command2; command3; ... ) & :
while ... do ( your script goes here, executed in a separate process ) & CHILD_PID = $! done
And also $! gives you the PID of the child process. What else do you need to know? When you reach running processes k , you need to wait for others. This is done using wait <PID> :
wait $CHILD_PID
If you want to wait for them all, just use wait .
This should be enough to implement the system.
source share