LinuxCommandLibrary

pdsh

Execute commands on multiple remote hosts

SYNOPSIS

pdsh [options] command...

PARAMETERS

-w host1,host2,...
    Specifies the target hosts on which to run the command. Hosts can be listed comma-separated.

-g group1,group2,...
    Specifies host groups to target. Host groups are typically defined in a configuration file.

-N max_threads
    Sets the maximum number of threads to use for parallel execution.

-f fanout
    Specifies the maximum number of simultaneous connections to remote hosts.

-t timeout
    Sets a timeout for remote command execution, in seconds.

-l username
    Specifies the username to use when connecting to remote hosts.

-e
    Display errors as they occur. By default, errors are displayed at the end.

-q
    Quiet mode: suppress standard output. Only errors are displayed.

-h
    Display usage information.

-V
    Display version information.

-R rcmd
    Specify the remote command to use for execution (e.g., ssh, rsh, exec).

-S
    Sequentially execute command on each host.

DESCRIPTION

pdsh is a parallel remote shell program designed to execute commands on multiple remote hosts simultaneously. It's particularly useful for managing clusters of machines, allowing administrators to run commands across a large number of nodes efficiently.

pdsh employs various remote shell methods, like ssh, rsh, or even custom modules, to execute commands in parallel. It allows for flexible host selection using a variety of host list formats and can handle errors gracefully, continuing execution on other hosts even if some fail. Its behavior can be controlled through numerous command-line options and environment variables, allowing the customization of parallel execution behavior.

pdsh is commonly used for tasks like software deployment, system monitoring, configuration management, and running parallel applications where commands need to be executed across a cluster.

CAVEATS

pdsh relies on the correct configuration of remote shell methods (ssh, rsh). Passwordless authentication via SSH keys is highly recommended for ease of use and security.

The performance of pdsh is directly affected by network latency and the efficiency of the chosen remote shell method.

HOST LISTS

pdsh supports several ways to specify target hosts. You can list them directly with the '-w' option, use groups defined in configuration files, or use wildcards to match hostnames. Consult the documentation for the different hostname expansion methods.

ERROR HANDLING

pdsh provides options for controlling how errors are handled. The '-e' option allows errors to be displayed immediately, while the default behavior is to display them at the end of execution. You can also configure pdsh to continue execution on other hosts even if some fail.

HISTORY

pdsh was developed to provide a more flexible and efficient parallel shell than existing tools like rsh or dsh. It aimed to improve scalability and provide finer-grained control over parallel execution. Over time, it has been enhanced with support for multiple remote shell methods and various configuration options.

SEE ALSO

ssh(1), rsh(1), pdcp(1), dsh(1)

Copied to clipboard