Ubuntu – Execute command before shutdown/reboot

execute-commandrebootshutdown

I have a machine running a couple of vagrant VM. The problem I have is that sometimes I forget to shutdown those VM before I shutdown or reboot my machine. Because of that my machine get stuck with this message: waiting for vboxnet0 to become free

I searched about solutions and I found this page :

http://en.kioskea.net/faq/3348-ubuntu-executing-a-script-at-startup-and-shutdown

I tried what they for shutdown, but it doesn't work.

I wrote an sh file for that command:

#!/bin/bash

cd ~/workspace/git/mediaservice
vagrant halt

any suggestions?

Best Answer

If your vagrant VMs are using VirtualBox, you can modify /etc/default/virtualbox and change the line that reads:

SHUTDOWN_USERS=""

to

SHUTDOWN_USERS="all"

That fixed it for me on Ubuntu 14.04.

Related Question