unraid 怎么用命令开机某一个虚拟机,想做一个延迟启动虚拟机的脚本 延迟会了 启动不...
source link: https://www.v2ex.com/t/778599
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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"
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK