Skip to content

Instantly share code, notes, and snippets.

@scemama
Created January 26, 2015 10:00
Show Gist options
  • Save scemama/6ffa7683ca6ee269dc3c to your computer and use it in GitHub Desktop.
Save scemama/6ffa7683ca6ee269dc3c to your computer and use it in GitHub Desktop.
Cron to keep VMs on
#!/bin/bash
VMS=$(VBoxManage list vms | cut -d ' ' -f 1 | tr '"' ' ')
for VM in $VMS
do
VBoxManage list runningvms | cut -d ' ' -f 1 | grep $VM > /dev/null
if [[ $? -ne 0 ]]
then
VBoxManage startvm $VM --type=headless
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment