我有进入每个服务器并获取输出的脚本。
EXCECUTE_CMD="$(find /tmp/customize -name 'customize.*.log' -mtime -1 -type f -print | wc -l)"
for server in $SERVERS
do
ssh -o StrictHostKeyChecking=no $server $EXCECUTE_CMD
echo "$server $EXCECUTE_CMD" > $text.txt
done
echo "file fullpath"; ls -ltra $text.txt
}
现在我无法获得输出,并且收到错误主机名:server1,server2。我需要获取并添加每个服务器中的所有输出,并作为总数打印在文件中。
答案1
EXCECUTE_CMD="$(find /tmp/customize -name 'customize.*.log' -mtime -1 -type f -print | wc -l)"
for server in ${SERVERS}
do
count=$(ssh -o StrictHostKeyChecking=no ${server} ${EXCECUTE_CMD})
echo "${server} ${count}" >> text.txt
done
echo "file fullpath" ${PWD}/text.txt