如何使用ssh命令连接到多台计算机并同时向每台计算机发送不同的命令

迈克·布朗

我需要连接多台计算机才能运行不同的程序。对于不同的计算机,我需要向他们发送不同的命令。如何使用ssh命令连接到多台计算机并向每台计算机发送不同的命令?我为每台计算机运行程序的命令是nohup Rscript program_i.R > program_i_out.txt待详细说明。我想使用3台计算机来运行3个程序。然后,我将发送

nohup Rscript program_1.R > program_1_out.txt 到第一台计算机,

nohup Rscript program_2.R > program_2_out.txt 到第二台计算机,

nohup Rscript program_3.R > program_3_out.txt 到第三台计算机。

科马克

尝试一下ssh -f user@host '<your command here>'

在ssh手册页中:

-f Requests ssh to go to background just before command execution. This is useful if ssh is going to ask for passwords or passphrases, but the user wants it in the background.

例如,如果我这样做ssh -f <my computer> 'echo "hello $(pstree -p | grep sshd | wc -l) person in ssh!",它将打印出来hello 1 person in ssh!

After it prints 2 the session automatically exits, but you do not have to wait for it to exit. If I do ssh -f <my computer> 'sleep 30 && echo "hello $(pstree -p | grep sshd | wc -l) person in ssh!"' it appears as if nothing has happened and I can do anything as normal, but 30 seconds later, it prints hello 1 person in ssh!.

Using the > redirect will redirect all stdout to a file, but all errors will still be printed to your screen. To avoid this, you can use &> to redirect all output, stdout and stderr, to a file.

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何使用ssh命令连接到多台计算机并同时向每台计算机发送不同的命令

如何向DHCP服务器发送不同的主机名?(使用伪造的计算机名连接到wifi)

向连接到当前计算机的用户发送消息

如何通过ssh通过同一命令询问多台计算机

尝试使用域将SSH连接到计算机

通过ssh通过Jumphost连接到多台计算机并收集一些信息

如何从命令行向Windows 10计算机发送通知

如何通过SSH连接到位于不同WLAN中的计算机?

如何通过SSH连接到位于不同WLAN中的计算机?

如何使用HDMI将计算机连接到电视?

我如何知道每台计算机使用多少带宽?

用于连接多台计算机并执行一些 wsus 相关命令的 powershell 脚本

如何使用ssh在远程Unix计算机上运行命令并在命令完成之前退出?

Powershell命令打开WSL会话,连接到远程计算机,然后在该计算机上调用脚本

CentOS 7:如何在无法连接到Internet的计算机上安装open-jdk?(使用yum install命令)

如何阅读多台计算机描述?

如何将在连接的计算机上运行的命令的输出发送到连接的计算机中的文件

如何使用SSH连接到另一台计算机(已安装Windows)?

如何并行化可以在多台计算机上分发任务的“ make”命令

运行Python命令SSH到计算机并在该计算机上运行MATLAB

使用ssh,如何在不退出的情况下在远程计算机上运行命令?

相同的 Makefile 在不同的计算机上执行不同的命令

从本地计算机连接到服务器-SSH

远程连接到计算机有哪些不同的方式?

如何使我的MVC 4应用程序能够从其他计算机访问,允许多台计算机连接到IIS 7.5上的我的站点

从远程计算机连接到MySQL

连接到远程CentOS计算机

从远程计算机连接到容器

在远程计算机上运行ssh并执行命令