Close inactive VMs

Discussions related to using VirtualBox on Linux hosts.
Post Reply
rosco18
Posts: 1
Joined: 16. Aug 2016, 12:31

Close inactive VMs

Post by rosco18 »

I would like to automatically close down VMs which have been inactive for (say) 15 minutes. By inactive I mean there has been no user keyboard or mouse input to the VM. Does VBoxManage provide a way of detecting such inactivity?
An alternative would be some script in the guest which could be used to detect inactivity and send a message to the host to trigger a shutdown. The screensaver is obviously monitoring inactivity but it doesn't seem to log its actions.

VirtualBox 7.0.6
Host: CentOS 7
Guest: Linux Mint 20
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Close inactive VMs

Post by scottgus1 »

I don't believe that there are any Virtualbox commands to catch such inactivity.

You can use "vboxmanage guestproperty get/set" to communicate text data between the host and VM when Guest Additions are installed in the VM.

Set a guestproperty with vboxmanage guestproperty set" on the host, then loop in the script with "vboxmanage guestproperty get" waiting for the guestproperty to reset. The script in the VM can call "vboxcontrol guestproperty set" to reset the guestproperty when the programmed inactivity occurs. Then the host script sees the reset guestproperty and shuts down the VM.
Post Reply