Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- If you want to execute a command on a set of nodes, you can install and use something dsh or parallel-ssh on your ubuntu.
- Or you can use the following few lines of code.
- This will come in handy when you don't have sudo access to install one of the above mentioned tools.
- Save the following lines of code and name the file parallel.sh (you can improvise - add it to path, etc)
- #!/bin/bash
- P1=""
- for i in `cat $1`
- do
- ssh $i "$2" | sed "s/^/$i: /" &
- P1=$P1" "$!
- done
- wait $P1
- Create a host files with each line in the following format and save the file
- <username>@<ip-address>
- eg:
- user1@10.1.1.1
- user1@10.1.1.2
- user1@10.1.1.3
- user2@10.1.1.4
- Execute a command on all the nodes using parallel.sh as follows
- ./parallel.sh <host-file-name> "<command>"
- eg:
- ./parallel.sh host-file "pwd"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement