I'm trying to execute command on multiple servers through ssh, that's what I'm trying to do:
for i in {1..3}; do `ssh nginx_$i ps aux | grep logstash`; done
But it tells me to install some package:
The program 'root' is currently not installed. You can install it by typing:
sudo apt-get install root-system-bin
I'm not convinced that I need to install it, because if I do
ssh nginx_1 ps aux | grep logstash
It works, and gives me the correct result.
PS Assuming that I have configured .ssh/config
file to connect to nginx_1
, nginx_2
and nginx_3
.
for i in {1..3}; do `ssh nginx_$i ps aux | grep logstash`; done ^ ^
Drop the backquotes. If you include them, the shell will try to execute the output of the command.
而不是for循环,应该使用pssh 。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.