1

所以我有一个烦人的问题。我有一个脚本可以更改给定文本文件的某些配置。要更改该特定文件,我必须首先销毁我的 KVM 上的虚拟机来宾。问题是每次它停止时,脚本的输出中都会有一个空格,如您所见:

vfp-8vr Found!
Check if vfp-8vr has stopped ................................. [OK]

Check if vfp-8vr node has changed ............................ [OK]
Check if vfp-8vr has started ................................. [OK]
vfp-9vr Found!
Check if vfp-9vr has stopped ................................. [OK]

Check if vfp-9vr node has changed ............................ [OK]
Check if vfp-9vr has started ................................. [OK]
vfp-10vr Found!
Check if vfp-10vr has stopped ................................. [OK]

Check if vfp-10vr node has changed ............................ [OK]
Check if vfp-10vr has started ................................. [OK]

我已将 /dev/null 包含在我的脚本中,因为它隐藏了输出,理论上它可以工作,但仍然有一个银行空间出现......

for i in "${arr[@]}"
do
  if [[ -n "$i" ]]
     then
         echo "$i Found!"

         virsh destroy $i &> /dev/null
         echo -e "Check if \e[32m$i\e[0m has stopped ................................. [OK]"

         virsh numatune $i $opt_node0
         echo -e "Check if \e[32m$i\e[0m node has changed ............................ [OK]"

         virsh start $i &> /dev/null
         echo -e "Check if \e[32m$i\e[0m has started ................................. [OK]"

  fi
done

有没有人知道如何virsh destroy在后台运行而不在输出中显示烦人的空间?

免责声明:我也已经使用[Command] > /dev/null 2>&1 &过,同样的事情:/

4

1 回答 1

0

傻我,我忘了添加 /dev/null 到 virsh numatune 命令:

Check if vfp-8vr has stopped ................................. [OK]
Check if vfp-8vr node has changed ............................ [OK]
Check if vfp-8vr has started ................................. [OK]
vfp-9vr Found!
Check if vfp-9vr has stopped ................................. [OK]
Check if vfp-9vr node has changed ............................ [OK]
Check if vfp-9vr has started ................................. [OK]
vfp-10vr Found!
Check if vfp-10vr has stopped ................................. [OK]
Check if vfp-10vr node has changed ............................ [OK]
Check if vfp-10vr has started ................................. [OK]

感谢社区!

于 2021-12-09T00:23:45.667 回答