• 请不要在回答技术问题时复制粘贴 AI 生成的内容
ETONG
V2EX  ›  程序员

unraid 怎么用命令开机某一个虚拟机,想做一个延迟启动虚拟机的脚本 延迟会了 启动不会

  •  
  •   ETONG · May 22, 2021 · 1761 views
    This topic created in 1841 days ago, the information mentioned may be changed or developed.

    Google 了一下 好像是用 virsh 命令,搜了一些网页好像没有启动虚拟机的选项

    找到了一个脚本不知道行不行,可有大佬了解的

    #!/bin/bash

    VM1="$1" VM2="$2"

    echo $VM1 echo $VM2

    if virsh list | grep -q " ${VM1} .*running" ; then virsh shutdown "${VM1}" fi

    echo "1" WAIT=0

    while virsh list | grep -q " ${VM1} .*running" ; do if [ $WAIT -lt 51 ]; then WAIT=$(($WAIT + 5)) sleep 5 echo $WAIT else echo "too long" break fi done

    if virsh list | grep -q " ${VM1} .*running" ; then virsh destroy "${VM1}" fi

    WAIT=0

    while virsh list | grep -q " ${VM1} .*running" ; do if [ $WAIT -lt 30 ]; then WAIT=$(($WAIT + 5)) sleep 5 echo $WAIT else echo "too long" break fi done

    virsh start "$VM2"

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2411 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 60ms · UTC 00:24 · PVG 08:24 · LAX 17:24 · JFK 20:24
    ♥ Do have faith in what you're doing.