I am trying to write a bash script that launches n commands in the background and then waits for each command to finish. I can easily get the time it took to execute all the commands using
time sh myscript.sh.
But I want to get the execution time for each command.
So lets say I have two commands and I launch them in my script like so:
echo "1" & echo "2" & wait
Now to time each command I have tried the following:
time echo "1" 1> /dev/null & time echo "2" 1> /dev/null & wait
But that seems to only print the overall time of the script (or something similar to it).
Am I going about this the wrong way?