Is there a simple way to do the equivalent of this, but run the two processes concurrently with bash
?
$ time sleep 5; sleep 8
time
should report a total of 8 seconds (or the amount of time of the longest task)
Is there a simple way to do the equivalent of this, but run the two processes concurrently with bash
?
$ time sleep 5; sleep 8
time
should report a total of 8 seconds (or the amount of time of the longest task)
time sleep 8 & time sleep 5
The &
operator causes the first command to run in the background, which practically means that the two commands will run concurrently.
Using sleeps as examples.
If you want to only time the first process, then
time sleep 10 & sleep 20
If you want to time both processes, then
time (sleep 10 & sleep 20)
Sorry my question may not have been exactly clear the first time around, but I think I've found an answer, thanks to some direction given here.
time sleep 5& time sleep 8
will time both processes while they run concurrently, then I'll just take the larger result.
$ time (sleep 5 & sleep 8 & wait)
real 0m8.019s
user 0m0.005s
sys 0m0.005s
Without any arguments, the shell built-in wait
waits for all backgrounded jobs to complete.