I like my VMs to run headless. I like my VMs to be powered on. Here is how.

as root

nano /bin/vboxlist.sc

and paste in the following

VBoxManage list vms | grep { | cut -d{ -f 1 | sed ‘s/”//g’ > /tmp/vboxlist
cat /tmp/vboxlist

exit saving and then

nano /bin/vboxon.sc

and paste in

vboxlist.sc
vboxon_list=’/tmp/vboxlist’
for VPS in `cat $vboxon_list`; do
echo starting “$VPS”
VBoxHeadless -startvm “$VPS” &
sleep 20
done
exit 0

save and exit and then

chmod +x /bin/*.sc

then as your regular user who executes the VMs. (often not root)

crontab -e

and enter

*/5 * * * * /bin/vboxon.sc

This will now launch your entire list of VMs in a headless mode every 5 minutes. If the VM is already running, it will simply fail to launch the VM and move onto the next. If you just want a list of VMs on the system you can type vboxlist.sc. If you want to manually turn on the VMs, you can type vboxon.sc

disclaimer: this was writtin on a debian VirtualBox host. The line “VBoxManage list vms | grep { | cut -d{ -f 1 | sed ‘s/”//g’ > /tmp/vboxlist” maybe different on different distributions or VirtualBox versions.