即使失败,在远程服务器上执行的命令也会返回 true。这是代码。
command="
sudo su - postgres -c 'pg_dump -Fc ${var[1]}'
"
if
ssh -n -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$username"@"${var[0]}" "$command" > "$folder_export"/"${var[0]}"/"$date"-"$time"-"${var[0]}"-"${var[1]}".dump
export_end=$date-$time
then
export=true
else
export=false
fi
我试图停止远程服务器上的 postgres。输出向我展示了这一点。
pg_dump: [archiver (db)] connection to database "coopweb" failed: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
但如果条件返回真。我不知道为什么。ssh 命令中的某些选项可能是错误的吗?或者问题出在哪里?
谢谢你。