EN
Bash - wait until sub-process or command is ended
6 points
In this short article, we would like to show how to wait until some run sub-process or command is ended under Bash.
Quick solution:
xxxxxxxxxx
1
2
3
# ...
4
5
some_command &
6
pid=$!
7
8
# ...
9
10
wait "$pid"
11
12
# ...
Where:
&
causes runningsome_command
in the background, letting to get ran processPID
by$!
,wait
blocks current script during process is run.
Hint: you can change
some_command
to path to any program or script.