Skip to content
Advertisement

how to send different commands to multiple hosts to run programs in Linux

I am an R user. I always run programs on multiple computers of campus. For example, I need to run 10 different programs. I need to open PuTTY 10 times to log into the 10 different computers. And submit each of programs to each of 10 computers (their OS is Linux). Is there a way to log in 10 different computers and send them command at same time? I use following command to submit program

JavaScript

Advertisement

Answer

First set up ssh so that you can login without entering a password (google for that if you don’t know how). Then write a script to ssh to each remote host to run the command. Below is an example.

JavaScript

This is a very simplistic example. You can do much better than this (for example, you can put the “.R” and the “.txt” file names into a variable and use that rather than explicitly listing every option in the case).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement