1
일부 원격 호스트에서 일부 명령을 실행하려고합니다. 파일에 ips.txt
(한 줄에 하나씩)의 ips 목록을 가지고 있습니다.bash 스크립트의 ssh가 루프를 종료합니다.
#!/bin/bash
while IFS= read -r wip; do
echo $wip
ssh [email protected]$wip "pkill pgm; cd /root/pgm; nohup ./pgm > /dev/null 2>&1 &"
echo "$wip end"
done < ips.txt
위의 스크립트를 실행하고 있습니다. 하지만 문제는 루프가 끝나는 첫 번째 ip를 읽은 후입니다. 하지만 ssh 줄을 제거하면 모든 ips가 인쇄됩니다.
https://unix.stackexchange.com/questions/107800/using-while-loop-to :
와
페이지를 교체 -ssh-to-multiple-servers – Pavel