6

How do I time a compound command when most but not all commands executed in parallel:

For example the command:

comd1 ; comd2 & comd3 & comd4 & comd5 &

I tried

time (comd1…)

But from the output I can speculate that only comd1 was timed because comd2 to comd5 usually are not so fast to finish executing when being executed alone.

1 Answer 1

5

You could add a wait to wait for all background processes.

Examples:

$ time (sleep 1; sleep 2 & sleep 4 & wait)
real    0m5.007s
user    0m0.004s
sys     0m0.005s

$ time (sleep 1; sleep 6 & sleep 4 & wait)
real    0m7.011s
user    0m0.005s
sys     0m0.003s

You must log in to answer this question.

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