Waiting for a background process to finish

Hello,
I am a novice shell script programmer. And facing this problem any help is appreciated.
I m writing a shell script and running few commands in it background as I have to run them simultaneously.
Sample code :

sql_prog &
sql_prog &
sql_prog &
echo "Process Completed"

Here sql_prog is user defined function which runs some sql queries.
The problem is as soon as it executes these last sql_prog it quickly prints the last statement. I want that the program should wait for last echo statement and print it only once all the above 3 sql_prog are finished.
Is there any easier way to do this.

Thanks

One way

sql_prog &
sql_prog &
sql_prog &
wait
echo "Process Completed"

1 Like

Fantastic, It worked and above all a very simple way. Many thanks for your help.