I run multiple VM's using VirtualBox on my laptop. Few time I forgot to shutdown the VM's prior to logging off, which caused me to loose my work. So, I decided to write a little script to save the state prior to logoff.
Add the following to your ~/.bash_logout
for vm in `/usr/bin/VBoxManage list runningvms | grep -E "^\"" | awk -F "\"" '{print $2}'`;
do
/usr/bin/logger -p local0.info -t VirtualBox "Saving state: $vm"
/usr/bin/VBoxManage controlvm $vm savestate | grep % | logger -p local0.info -t VirtualBox
done
Sample /var/log/messages output:
Oct 7 00:43:46 moonshine VirtualBox: Saving state: lamp32
Oct 7 00:43:48 moonshine VirtualBox: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Cheers,
VVK
No comments:
Post a Comment