How to check execution time of a bash script that starts background processes

Viewed 1569

I have a bash script which runs 4 different process in the background and you can see the code below:

declare -a arr=("seed_automation_data_1" "seed_automation_data_2" "seed_automation_data_3" "seed_automation_data_4")
command="bundle exec rake db:seed:"
for i in "${arr[@]}"
do
   $command$i &
done

This bash script is actually running a rake task in rails framework.

$command$i &

This particular line is starting four different process in the background:-

bundle exec rake db:seed:seed_automation_data_1
bundle exec rake db:seed:seed_automation_data_2
bundle exec rake db:seed:seed_automation_data_3
bundle exec rake db:seed:seed_automation_data_4

Since there are four different process running in the background I am not able to know when the bash script is FINISHED or calculate the execution-time of it.

Is there a way I can print some statements which will show that the script is finished running?

2 Answers
Related