pdsh(1)
okay bestie, grab a snack π because this is pdsh(1) from the General Commands Manual and it's genuinely iconic. it's giving "run one command on a hundred hosts at once and don't even break a sweat." let's go π
β¨ NAME β¨
pdsh β issue commands to groups of hosts in parallel π«Ά
β¨ SYNOPSIS β¨
pdsh [options]... command
β¨ DESCRIPTION β¨
so pdsh is basically a variant of the rsh(1) command. but here's the glow-up: rsh(1) runs a command on one remote host, and pdsh runs multiple remote commands in parallel. main character energy fr.
pdsh uses a "sliding window" (or fanout) of threads to conserve resources on the initiating host while still allowing some connections to time out. resource girlie behavior, we love to see it π
when pdsh receives SIGINT (that's ctrl-C), it lists the status of current threads. a second SIGINT within one second terminates the program. and if you issue ctrl-Z within one second of ctrl-C, pending threads may be canceled. "pending threads" = the ones that haven't been initiated yet, or are still in the process of connecting to the remote host. no cap.
if a remote command is not specified on the command line, pdsh runs interactively β prompting for commands and executing them when terminated with a carriage return. in interactive mode, target nodes that time out on the first command are not contacted for subsequent commands, and commands prefixed with an exclamation point will be executed on the local system. cute, right?
the core functionality of pdsh may be supplemented by dynamically loadable modules. these modules may provide:
- a new connection protocol (replacing the standard
rcmd(3)protocol used byrsh(1)), - filtering options (e.g. removing hosts that are "down" from the target list),
- and/or host selection options (e.g.,
-aselects all hosts from a configuration file).
by default, pdsh must have at least one "rcmd" module loaded. see the RCMD MODULES section for more info π
β¨ RCMD MODULES β¨
the method by which pdsh runs commands on remote hosts may be selected at runtime using the -R option (see OPTIONS below). this functionality is ultimately implemented via dynamically loadable modules, so the list of available options may be different from installation to installation. a list of currently available rcmd modules is printed when using any of the -h, -V, or -L options. the default rcmd module will also be displayed with the -h and -V options. π
a list of rcmd modules currently distributed with pdsh follows.
rshβ uses an internal, thread-safe implementation of BSDrcmd(3)to run commands using the standardrsh(1)protocol.execβ executes an arbitrary command for each target host. the first of thepdshremote arguments is the local command to execute, followed by any further arguments. some simple parameters are substitued on the command line, including%hfor the target hostname,%ufor the remote username, and%nfor the remote rank[0-n](to get a literal%use%%). for example, the following would duplicate using the ssh module to runhostname(1)across the hostsfoo[0-10]:
pdsh -R exec -w foo[0-10] ssh -x -l %u %h hostname
and this command line would run grep(1) in parallel across the files console.foo[0-10]:
pdsh -R exec -w foo[0-10] grep BUG console.%h
sshβ uses a variant ofpopen(3)to run multiple copies of thessh(1)command.mrshβ this module uses themrsh(1)protocol to execute jobs on remote hosts. the mrsh protocol uses a credential based authentication, forgoing the need to allocate reserved ports. in other aspects, it acts just like rsh. remote nodes must be runningmrshd(8)in order for the mrsh module to work.krb4β the krb4 module allows users to execute remote commands after authenticating with kerberos. of course, the remote rshd daemons must be kerberized.xcpuβ the xcpu module uses the xcpu service to execute remote commands.
β¨ OPTIONS β¨
the list of available options is determined at runtime by supplementing the list of standard pdsh options with any options provided by loaded rcmd and misc modules. in some cases, options provided by modules may conflict with each other. in these cases, the modules are incompatible and the first module loaded wins. π
Standard target nodelist options
-w TARGETS,...β target and or filter the specified list of hosts.
do not use with any other node selection options (e.g. -a, -g, if they are available). no spaces are allowed in the comma-separated list. arguments in the TARGETS list may include normal host names, a range of hosts in hostlist format (see HOSTLIST EXPRESSIONS), or a single - character to read the list of hosts on stdin.
if a host or hostlist is preceded by a - character, this causes those hosts to be explicitly excluded. if the argument is preceded by a single ^ character, it is taken to be the path to file containing a list of hosts, one per line. if the item begins with a / character, it is taken as a regular expression on which to filter the list of hosts (a regex argument may also be optionally trailed by another /, e.g. /node.*/). a regex or file name argument may also be preceeded by a minus - to exclude instead of include thoses hosts.
a list of hosts may also be preceded by "user@" to specify a remote username other than the default, or "rcmd_type:" to specify an alternate rcmd connection type for these hosts. when used together, the rcmd type must be specified first, e.g. "ssh:user1@host0" would use ssh to connect to host0 as user "user1." π¦
-x host,host,...β exclude the specified hosts.
may be specified in conjunction with other target node list options such as -a and -g (when available). hostlists may also be specified to the -x option (see the HOSTLIST EXPRESSIONS section below). arguments to -x may also be preceeded by the filename (^) and regex (/) characters as described above, in which case the resulting hosts are excluded as if they had been given to -w and preceeded with the minus - character.
Standard pdsh options
-Sβ return the largest of the remote command return values.-kβ fail fast on connect failure or non-zero return code.-hβ output usage menu and quit. a list of available rcmd modules will also be printed at the end of the usage message.-sβ only on AIX, separate remote command stderr and stdout into two sockets.-qβ list option values and the target nodelist and exit without action.-bβ disable ctrl-C status feature so that a single ctrl-C kills parallel job. (batch mode) π-luser β this option may be used to run remote commands as another user, subject to authorization. for BSD rcmd, this means the invoking user and system must be listed in the user's.rhostsfile (even for root).-tseconds β set the connect timeout. default is 10 seconds. this option may also be set via thePDSH_CONNECT_TIMEOUTenvironment variable.-useconds β set a limit on the amount of time a remote command is allowed to execute. default is no limit. see note in LIMITATIONS if using-uwith ssh. this option may also be set via thePDSH_COMMAND_TIMEOUTenvironment variable.-fnumber β set the maximum number of simultaneous remote commands to number. the default is 32.-Rname β set rcmd module to name. this option may also be set via thePDSH_RCMD_TYPEenvironment variable. a list of available rcmd modules may be obtained via the-h,-V, or-Loptions. the default will be listed with-hor-V.-Mname,... β when multiple misc modules provide the same options topdsh, the first module initialized "wins" and subsequent modules are not loaded. the-Moption allows a list of modules to be specified that will be force-initialized before all others, in-effect ensuring that they load without conflict (unless they conflict with eachother). this option may also be set via thePDSH_MISC_MODULESenvironment variable.-Lβ list info on all loadedpdshmodules and quit.-Nβ disablehostname:prefix on lines of output.-dβ include more complete thread status whenSIGINTis received, and display connect and command time statistics on stderr when done. also, display any module loading errors to stderr, including option conflicts.-Vβ outputpdshversion information, along with list of currently loaded modules, and exit.
machines module options
-aβ target all nodes from machines file.
πΈ genders module options πΈ
ok so first, a lil extra beyond the flags themselves: the genders database can also carry an attribute called pdsh_rcmd_type, and if a host has it, that attribute sets an alternate rcmd connect type for that host instead of whatever pdsh's default is. Like, say your genders file has this line:
host0 pdsh_rcmd_type=ssh
then pdsh would use ssh to connect to host0 even if rsh was the default. π
You can still override it from the commandline with the "rcmd_type:host0" syntax. icon behavior, fr.
-Aβ targets every single node in the genders database. All of them. If you want some hosts skipped by default, go look at-abelow bestie.-aβ targets all nodes in the genders database except the ones carrying the"pdsh_all_skip"attribute. It's literally shorthand for runningpdsh -A -X pdsh_all_skip ...β¨-g attr[=val][,attr[=val],...]β targets nodes matching any of the genders attributes you name (values optional). β οΈ Conflicts with the-aoption. If you pair it with other node selection options like-w, then-gselects from the node list you supplied instead of from the genders file as a whole. Otherwise? It targets the alternate hostnames in the genders database by default β and the-ioption from the genders module can translate those into canonical genders hostnames. If your installed genders supports it, the attributes you hand to-gcan also be genders queries. Those query the genders database for the union, intersection, difference, or complement of attributes and values: union is two pipes ('||'), intersection is two ampersands ('&&'), difference is two minus signs ('--'), and complement is a tilde ('~'). Parentheses can change the order of operations. Peep thenodeattr(1)manpage for query examples. π₯-X attr[=val][,attr[=val],...]β excludes nodes matching any of the specified genders attributes (values optional). Works in combination with any of the other node selection options (e.g.-w,-g,-a).-Xcan also take the form of genders queries β see the docs for the genders-goption for the deets on those.-iβ requests translation between canonical and alternate hostnames. π¦-F filenameβ reads genders info from filename instead of the system default genders file. If filename isn't an absolute path, it's taken relative to the directory given by thePDSH_GENDERS_DIRenvironment variable (/etcby default). You can also point at an alternate genders file with thePDSH_GENDERS_FILEenvironment variable. π
π nodeupdown module options π
-vβ kicks out target nodes that libnodeupdown considers "down". bye felicia π
β slurm module options β
The slurm module lets pdsh target nodes based on currently running SLURM jobs. It's typically called after all the other node selection options have been processed, and if nothing has been selected, the module tries to read a running jobid from the SLURM_JOBID environment variable (which gets set when you're running under a SLURM allocation). If SLURM_JOBID points at an invalid job, it's silently ignored. π
-j jobid[,jobid,...]β targets the list of nodes allocated to the SLURM job jobid. Can be used multiple times to target multiple SLURM jobs. The special argument"all"targets every node running SLURM jobs, like-j all. π-P partition[,partition,...]β targets the list of nodes contained in the SLURM partition partition. Use it multiple times for multiple partitions, and/or hand it partitions in a comma-delimited list.-C feature[,feature,...]β restricts the selected nodes to SLURM nodes that have one of the specified features active. Should be used together with other node selectors, and it filters the resulting list. Any node that doesn't have one of the specified features (or isn't a SLURM node at all) gets excluded. π«
π torque module options π
The torque module lets pdsh target nodes based on currently running Torque/PBS jobs. Same energy as slurm: it's typically called after all other node selection options have been processed, and if no nodes have been selected, the module tries to read a running jobid from the PBS_JOBID environment variable (set when you're running under a Torque allocation).
-j jobid[,jobid,...]β targets the list of nodes allocated to the Torque job jobid. Use it multiple times to target multiple Torque jobs. π
π§ dshgroup module options π§
The dshgroup module lets pdsh use dsh (or Dancer's shell) style group files from /etc/dsh/group/ or ~/.dsh/group/. The default search path can be overridden with the DSHGROUP_PATH environment variable β a colon-separated list of directories to search. Default value for DSHGROUP_PATH is /etc/dsh/group.
-g groupname,...β targets nodes in the dsh group file"groupname", found in either~/.dsh/group/groupnameor/etc/dsh/group/groupname. πΈ-X groupname,...β excludes nodes in the dsh group file"groupname."
And here's a lil pdsh glow-up: dshgroup files may optionally include other dshgroup files via a special #include STRING syntax. The argument to #include can be either a file path or a group name β if it's a group name, the path used to search for the group file is the same as if the group had been given to -g. π«Ά
π« netgroup module options π«
The netgroup module lets pdsh use standard netgroup entries to build lists of target hosts (/etc/netgroup or NIS).
-g groupname,...β targets nodes in netgroup"groupname."-X groupname,...β excludes nodes in netgroup"groupname."
β¨ ENVIRONMENT VARIABLES β¨
PDSH_RCMD_TYPEβ equivalent to the-Roption. Its value sets the default rcmd module pdsh uses (e.g.ssh,rsh).PDSH_SSH_ARGSβ overrides the standard arguments pdsh passes to thessh(1)command ("-2 -a -x -l%u %h"). Using the parameters%u,%h, and%n(as documented in the rcmd/exec section above) is optional. If those parameters are missing, pdsh appends them to the ssh commandline, because it assumes they're mandatory. no cap.PDSH_SSH_ARGS_APPENDβ appends extra options to thessh(1)command pdsh invokes. SoPDSH_SSH_ARGS_APPEND="-q"runs ssh in quiet mode, and"-v"bumps up ssh's verbosity. (Note: these arguments are actually prepended to the ssh commandline so they land before any target hostname argument to ssh.)WCOLLβ if no other node selection option is used, you can set this to a filename that pdsh reads a list of target hosts from. The file should have a list of hosts, one per line β though each line may contain a hostlist expression, see HOSTLIST EXPRESSIONS below. πDSHPATHβ if set, the path inDSHPATHis used as thePATHfor the remote processes.FANOUTβ sets the pdsh fanout (see the description of-fabove).
π HOSTLIST EXPRESSIONS π
Like the sections above mentioned, pdsh accepts lists of hosts in the general form: prefix[n-m,l-k,...], where n < m and l < k, etc., as an alternative to spelling out explicit host lists. Don't get it twisted with regular expression character classes (also written with []). For example, foo[19] is not an expression matching foo1 or foo9 β it's the degenerate hostlist foo19. π
The hostlist syntax is meant purely as a convenience on clusters with a "prefixNNN" naming convention, and specifying ranges should not be considered necessary β the list foo1,foo9 could be written as such, or as the hostlist foo[1,9].
Some 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
Friendly reminder bestie: some shells interpret brackets ('[' and ']') for pattern matching. Depending on your shell, you may need to wrap ranged lists in quotes. For example, in tcsh, that first example above should be run as:
pdsh -w "foo[01-05]" command
π ORIGIN π
Originally a rewrite of IBM dsh(1) by Jim Garlick <garlick@llnl.gov> on LLNL's ASCI Blue-Pacific IBM SP system. It is now used on Linux clusters at LLNL. π
π LIMITATIONS π
When you're using ssh for remote execution, expect the stderr of ssh to be folded in with that of the remote command. And when pdsh invokes it, ssh can't prompt for passwords if RSA/DSA keys are configured properly, etc. For ssh implementations that support a connect timeout option, pdsh tries to use that option to enforce the timeout (e.g. -oConnectTimeout=T for OpenSSH) β otherwise, connect timeouts are just not supported when using ssh. π And finally, there is no reliable way for pdsh to ensure remote commands are actually terminated when you use a command timeout. So if -u is used with ssh, commands may be left running on remote hosts even after the timeout has killed the local ssh processes. π
The number of nodes pdsh can simultaneously execute remote jobs on is limited by the max number of threads that can be created concurrently, plus the availability of reserved ports in the rsh module. On systems implementing Posix threads, that limit is typically defined by the constant PTHREADS_THREADS_MAX.
β FILES β
ok bestie, this section is literally empty in the original. nothing here. we move. π
π SEE ALSO π
rsh(1), ssh(1), dshbak(1), pdcp(1)
and that's the whole page, you're officially a pdsh girlie now π«Ά this was pdsh(1) from the linux-gnu crew β go forth and fan out responsibly, mwah π
β¨
π¦ where this page comes from
- debian trixie: pdsh 2.35-2 Β· GPL-2.0-or-later
- ubuntu questing: pdsh 2.35-2
- ubuntu resolute: pdsh 2.35-3 Β· GPL-2.0-or-later
- ubuntu stonking: pdsh 2.36-1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms