Home:ALL Converter>Script to shutdown Linux Hostwhen Virtualbox Guest Windows is shutdown?

Script to shutdown Linux Hostwhen Virtualbox Guest Windows is shutdown?

Ask Time:2016-10-26T19:21:25         Author:Deltatash

Json Formatter

I'm wondering if it's possible to auto shutdown a Linux Host when a Windows guest in Virtualbox is shutdown. I'm guessing some sort of script could do this?

Host: Linux Mint Guest: Windows 7 and Windows 10.

When the user presses shutdown in Windows it would be good if Linux could also shutdown automatically shortly after the guest has safely shutdown.

Author:Deltatash,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/40260993/script-to-shutdown-linux-hostwhen-virtualbox-guest-windows-is-shutdown
Hardy Rust :

You can use scrpit in cron, that runs every 5 minutes or so. Something like that:\n\n#!/bin/bash\nVM_NAME='your_vm'\nvboxmanage showvminfo $VM_NAME | grep -qE 'State: +powered off' && shutdown -h\n\n\nNote, that it will shutdown any time, when VM is not running.",
2016-10-26T12:05:43
Runcy Oommen :

There's a crude hackish way to do this. Here goes:\n\nAnytime a guest image is shutdown, VirtualBox writes the current config back as a .vbox file (located under $HOME/.vbox)\n\n\nWrite a simple shell script which would check if the date modified matches with the current time and initiate a shutdown process of your Linux box.\nCreate a cron job that would run this script every 45 seconds for instance.\n\n\nPS: You can make your script more intelligent by checking a buffer range of time - say modified within the last 5 minutes. By doing this, you can increase the cron job frequency to run every 4.45 minutes for efficiency.\n\nPS2: This will trigger your host machine shutdown if you modify VirtualBox config when VM is running or just edit the config, since you modified the config.",
2016-10-26T12:09:47
yy