脚本
#!/bin/bash
#停止所有虚拟机
# 获取所有虚拟机的ID列表
VMIDS=$(qm list | awk 'NR>1 {print $1}')
# 遍历每个虚拟机ID并停止虚拟机
for VMID in $VMIDS; do
echo "Stopping VM ID $VMID..."
qm stop $VMID
done
echo "All VMs have been stopped."
#停止所有容器
for ctid in $(pct list | awk 'NR>1 {print $1}'); do
echo "Stopping CT ID $ctid..."
pct stop $ctid
done
echo "All CTs have been stopped."
发表评论 取消回复