Halt all Vagrant/VirtualBox VMs one-liner

If you’re using Vagrant to control your dev VMs on a headless server it’s easy to lose track of the number of running machines.

Here’s a one-liner to gracefully shut-down all of them to free up some resources.

<span class="lang:default decode:true  crayon-inline ">for VM in `VBoxManage list runningvms | awk '{ print $2; }'`; do VBoxManage controlvm $VM poweroff; done</span>Code language: JavaScript (javascript)

Comments

2 responses to “Halt all Vagrant/VirtualBox VMs one-liner”

  1. […] used Darren Beale’s one-liner in the /etc/init.d/vagrant file, and it works […]

  2. I feel your pain! WebSphere is ridiculous. We deiedcd to just use Tomcat for local development, then deploy to websphere. I’ve been doing a lot of dev ops lately too Jenkins, ant, bash build scripts. Maybe not as fun as app development, but at least we can get stuff done. I hope you got your problems solved.

Leave a Reply

Your email address will not be published. Required fields are marked *