0

I have three vagrant boxes I usually need simultaneously so I created a Makefile to start them all at once. Well, one after the other actually.

The Makefile looks like this basically:

up:
        cd box1 && vagrant up;
        cd box2 && vagrant up;
        cd box3 && vagrant up;

They are starting one after the other, which means it takes a lot of time. But a lot of that time is just waiting, there is not a lot happening. So I figured I want to start them in parallel to reduce the needed time.

Simply putting an & after vagrant up doesn't work. Neither if I put it between $(), "" or ``.

What do I need to do to make these boxes start in parallel?

I use zsh as shell BTW.

  • make -j N starts multiple jobs concurrently, that is probably what you should use. Or invoke parallel. You can also make a shell script that starts them all (using &), but that defeats the purpose of the Makefile. – Anthon Sep 11 '17 at 7:10
  • @Anthon can you give an example of how to use make -j N? The documentation is not clear for me and I cannot find good examples. – Dennis Haarbrink Sep 13 '17 at 8:27
1

I can answer this question myself now. The Makefile should look like this:

.PHONY: up box1_up box2_up box3_up

up: box1_up box2_up box3_up

box1_up:
    cd box1 && vagrant up;

box2_up:
    cd box2 && vagrant up;

box3_up:
    cd box3 && vagrant up;

And invoke like this: make -j3 up

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.