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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.