pdsh – run a command in parallel on multiple cluster nodes
pdsh – Parallel Distributed Shell.
You may have to run a commnd in parallel on multiple node if you have a cluster of machines. Generally, a HPC cluster.
There are many utilities that will help you to achive this task. pdsh is one of the best tool.
Usage:
Ex: Let us say you have nodes 25 compute nodes from cn001 to cn025. To run “date” command on all these nodes, do as follows:
#pdsh -w cn[001-025] date
The above command will output date from nodes cn001 to cn025
Note: passwordless ssh must have been configured for pdsh to work.
Some more examples of usage follow:
Run command on foo01,foo02,…,foo05 pdsh -w foo[01-05] command Run command on foo7,foo9,foo10
pdsh -w foo[7,9-10] command
- Run command on foo0,foo4,foo5
pdsh -w foo[0-5] -x foo[1-3] command
- A suffix on the hostname is also supported:Run command on foo0-eth0,foo1-eth0,foo2-eth0,foo3-eth0
pdsh -w foo[0-3]-eth0 command
As a reminder to the reader, some shells will interpret brackets (‘[‘ and ‘]’) for pattern matching. Depending on your shell, it may be necessary to enclose ranged lists within quotes. For example, in tcsh, the first example above should be executed as:
pdsh -w "foo[01-05]" command