Remotely wake VM?

Go to solution Solved by Squid,

Recommended Posts

I only need my VM to be accessible 2 days a week so is there a simple way I could somehow trigger a power on of the VM?


I have nextcloud so I thought is there a way using a script that I could watch for the presence of a file or a change of a file to trigger?

Link to comment

In case anyone ever asks, I got this working quite simply by doing the following:




inotifywait -m -e modify "$f" --format "%e" | while read -r event; do
    if [ "$event" == "MODIFY" ]; then

        cat $f
        contents=$( cat $f )
        if [ $contents == "on" ]; then

                echo "Starting VM"
                virsh start "VM NAMe"

        elif [ $contents == "off" ]; then

                echo "Stopping VM"
                virsh shutdown "VM NAMe"




So basically create a text file on your nextcloud instance and then find the path to it via the terminal. If you then edit the file via the nextcloud web interface or mobile app and set the contents to "on" or "off" it will power the VM on or off accordingly.

Edited by allanp81
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.