Forrest logo
back to the qm tool

qm-wait:tldr:afe21

qm-wait: Send a shutdown request, then wait until the virtual machine is stopped with a 10 second timeout.
$ qm shutdown ${vm_id} && qm wait --timeout ${10} ${vm_id}
try on your machine

This command is a script for shutting down a virtual machine (VM) using the "qm" command-line tool. Let's break it down step by step:

  1. qm shutdown ${vm_id}: This part of the command initiates the shutdown process for a specific VM identified by vm_id. The ${vm_id} is a placeholder, and you would need to replace it with the actual ID of the VM you want to shut down. The qm shutdown command sends a shutdown signal to the VM, encouraging it to gracefully shut down any running processes and prepare for the shutdown.

  2. &&: This is a control operator used to combine two commands in a way that the second command (qm wait) will only execute if the first command (qm shutdown) is successful. It acts as a logical "AND" operator.

  3. qm wait --timeout ${10} ${vm_id}: This part of the command waits for the VM to fully shutdown. The qm wait command is used to pause the script execution until the VM identified by vm_id has completely shut down. The --timeout option specifies the maximum time to wait for the VM shutdown, and ${10} is a placeholder for the amount of time to wait (in this case, 10 seconds). You would need to replace ${10} with the desired timeout period.

In summary, this command initiates the shutdown of a VM, and if the shutdown is successful, it waits for the VM to completely shut down within a specified timeout period before proceeding with the rest of the script.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the qm tool