上传脚本到服务器命令_脚本:在服务器列表上运行命令

上传脚本到服务器命令

I frequently run some commands/scripts on a batch of servers whose IPs are already collected in a file. I usually use a simple loop and call the ssh to run these commands remotely and automatically. This operation, however, is common and can be abstracted into a separate script.

我经常在一批IP已经收集在文件中的服务器上运行一些命令/脚本。 我通常使用一个简单的循环并调用ssh来远程自动运行这些命令。 但是,此操作很常见,可以抽象为单独的脚本

Here is the script that I come up with for running commands automatically on a batch of servers:

这是我用来在一批服务器上自动运行命令的脚本:

batch-cmd.sh.

批处理cmd.sh。

The usage:

用法:

usage: ./batch-cmd.sh file cmd
Each host in one line in the file

The mechanism is to use ssh to run a command remotely. For example, to run command “ls” on remote host $host, we just run

机制是使用ssh远程运行命令 。 例如,要在远程主机$host上运行命令“ ls”,我们只需运行

ssh $host "ls"

If the current user can log on $host without password, it is automatically executed.

如果当前用户可以不用密码登录$host ,它将自动执行。

翻译自: https://www.systutorials.com/script-running-commands-on-a-list-of-servers/

上传脚本到服务器命令

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值