3

I have a script s:

echo a &
echo b &
echo c &

Now I want to know how much time it will take for the script to finish. I try

time bash s

But it gives me an immediate result which is not the correct one(my script is of course much more complicated than that I've written here and takes a lot of time) How can I ask time to wait for all the subprocesses to finish.

1 Answer 1

4

Add wait to the very end of the script. This will make the script wait for all background processes to exit before continuing.

The new script:

echo a &
echo b &
echo c &

wait

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .