How to close all virtual machines (vagrant) at once on Linux.

As simple as that:

This may be trivial to someone but I have been struggling with this almost whole day. Usually I have lots of vms running at once for test purposes and I was wondering if they can be all closed at same time without constantly changing directories and typing “vagrant halt”

So what does this magic command?

First part is simple

This just lists all running vms in our system. This command returns something like this:

After that we take name of each running vms and command

will convert it to this form

So in the end system will run command equivalent to:

Tip.
You can add to your rc0.d directory script to close all vms during shutdown.

Mar 30, 2015 | Posted by in Blog, Linux, Vagrant | 1 comment

Comments (One Response)

Add Your Comment

Your email address will not be published.