Debian Codegraph @

doc/txt/clush.txt

raw
1 =========
2 clush
3 =========
4
5 -----------------------------------
6 execute shell commands on a cluster
7 -----------------------------------
8
9 :Author: Stephane Thiell
10 :Date: 2026-07-16
11 :Copyright: GNU Lesser General Public License version 2.1 or later (LGPLv2.1+)
12 :Version: 1.10.1
13 :Manual section: 1
14 :Manual group: ClusterShell User Manual
15
16
17 SYNOPSIS
18 ========
19
20 ``clush`` ``-a`` | ``-g`` *group* | ``-w`` *nodes* [OPTIONS]
21
22 ``clush`` ``-a`` | ``-g`` *group* | ``-w`` *nodes* [OPTIONS] *command*
23
24 ``clush`` ``-a`` | ``-g`` *group* | ``-w`` *nodes* [OPTIONS] --copy
25 *file* | *dir* [ *file* | *dir* ...] [ --dest *path* ]
26
27 ``clush`` ``-a`` | ``-g`` *group* | ``-w`` *nodes* [OPTIONS] --rcopy
28 *file* | *dir* [ *file* | *dir* ...] [ --dest *path* ]
29
30 DESCRIPTION
31 ===========
32 ``clush`` is a program for executing commands in parallel on a cluster and for
33 gathering their results. ``clush`` executes commands interactively or can be
34 used within shell scripts and other applications. It is a partial front-end
35 to the ClusterShell library that ensures a light, unified and robust parallel
36 command execution framework. Thus, it allows traditional shell scripts to
37 benefit from some of the library features. ``clush`` currently makes use of
38 the Ssh worker of ClusterShell, by default, that only requires ``ssh``\(1)
39 (OpenSSH SSH client).
40
41
42 INVOCATION
43 ==========
44
45 ``clush`` can be started non-interactively to run a shell *command*, or can
46 be invoked as an interactive shell. To start a ``clush`` interactive session,
47 invoke the ``clush`` command without providing *command*.
48
49 Non-interactive mode
50 When ``clush`` is started non-interactively, the *command* is executed on
51 the specified remote hosts in parallel. If option ``-b`` or ``--dshbak``
52 is specified, ``clush`` waits for command completion and then displays
53 gathered output results.
54
55 The ``-w`` option allows you to specify remote hosts by using ClusterShell
56 NodeSet syntax, including the node groups ``@group`` special syntax and the
57 ``Extended Patterns`` syntax to benefit from NodeSet basic arithmetic
58 (like ``@Agroup\&@Bgroup``). See EXTENDED PATTERNS in ``nodeset``\(1) and
59 also ``groups.conf``\(5) for more information.
60
61 Unless the option ``--nostdin`` (or ``-n``) is specified, ``clush`` detects
62 when its standard input is connected to a terminal (as determined by
63 ``isatty``\(3)). If actually connected to a terminal, ``clush`` listens to
64 standard input when commands are running, waiting for an `Enter` key press.
65 Doing so will display the status of current nodes. If standard input is not
66 connected to a terminal, and unless the option ``--nostdin`` is specified,
67 ``clush`` binds the standard input of the remote commands to its own standard
68 input, allowing scripting methods like:
69
70 | # echo foo | clush -w node[40-42] -b cat
71 | ---------------
72 | node[40-42]
73 | ---------------
74 | foo
75
76 Please see some other great examples in the EXAMPLES section below.
77
78 Interactive session
79 If a *command* is not specified, and its standard input is connected to a
80 terminal, ``clush`` runs interactively. In this mode, ``clush`` uses the GNU
81 ``readline`` library to read command lines. Readline provides commands for
82 searching through the command history for lines containing a specified
83 string. For instance, type Control-R to search in the history for the next
84 entry matching the search string typed so far. ``clush`` also recognizes
85 special single-character prefixes that allow the user to see and modify
86 the current nodeset (the nodes where the commands are executed).
87
88 Single-character interactive commands are:
89 clush> ?
90 show current nodeset
91 clush> @<NODESET>
92 set current nodeset
93 clush> +<NODESET>
94 add nodes to current nodeset
95 clush> -<NODESET>
96 remove nodes from current nodeset
97 clush> !COMMAND
98 execute COMMAND on the local system
99 clush> =
100 toggle the output format (gathered or standard mode)
101
102 To leave an interactive session, type ``quit`` or Control-D.
103
104 Local execution ( ``--worker=exec`` or ``-R exec`` )
105 Instead of running provided command on remote nodes, ``clush`` can use the
106 dedicated *exec* worker to launch the command *locally*, for each node.
107 Some parameters could be used in the command line to make a different
108 command for each node. ``%h`` or ``%host`` will be replaced by node name and
109 ``%n`` or ``%rank`` by the remote rank [0-N] (to get a literal % use %%).
110 ``%hosts`` will be replaced by the full target nodeset, in which case the
111 command is executed only once.
112
113 File copying mode ( ``--copy`` )
114 When ``clush`` is started with the ``-c`` or ``--copy`` option, it will
115 attempt to copy specified *files* and/or *directories* to the provided
116 cluster nodes. The ``--dest`` option can be used to specify a single
117 path where all the file(s) should be copied to on the target nodes.
118 In the absence of ``--dest``, ``clush`` will attempt to copy each file or
119 directory found in the command line to their same location on the
120 target nodes.
121
122 Reverse file copying mode ( ``--rcopy`` )
123 When ``clush`` is started with the ``--rcopy`` option, it will attempt to
124 retrieve specified *file* and/or *dir* from provided cluster nodes. If the
125 ``--dest`` option is specified, it must be a directory path where the files
126 will be stored with their hostname appended. If the destination path is not
127 specified, it will take each *file* or *directory*'s parent directory as the
128 local destination.
129
130
131
132 OPTIONS
133 =======
134
135 --version show ``clush`` version number and exit
136 -s GROUPSOURCE, --groupsource=GROUPSOURCE
137 optional ``groups.conf``\(5) group source to use
138 -n, --nostdin do not watch for possible input from stdin; this should be used when ``clush`` is run in the background (or in scripts).
139 --groupsconf=FILE use alternate config file for ``groups.conf``\(5)
140 --conf=FILE use alternate config file for ``clush.conf``\(5)
141 -O <KEY=VALUE>, --option=<KEY=VALUE>
142 override any key=value ``clush.conf``\(5) options (repeat as needed)
143
144 Selecting target nodes:
145 -w NODES nodes where to run the command
146 -x NODES exclude nodes from the node list
147 -a, --all run command on all nodes
148 -g GROUP, --group=GROUP
149 run command on a group of nodes
150 -X GROUP exclude nodes from this group
151 --hostfile=FILE, --machinefile=FILE
152 path to a file containing a list of single hosts, node sets or node groups, separated by spaces and lines (may be specified multiple times, one per file)
153 --topology=FILE topology configuration file to use for tree mode
154 --pick=N pick N node(s) at random in nodeset
155
156 Output behavior:
157 -q, --quiet be quiet, print essential output only
158 -v, --verbose be verbose, print informative messages
159 -d, --debug output more messages for debugging purpose
160 -G, --groupbase do not display group source prefix (always ``@groupname``)
161 -L disable header block and order output by nodes; if -b/-B is not specified, ``clush`` will wait for all commands to finish and then display aggregated output of commands with same return codes, ordered by node name; alternatively, when used in conjunction with -b/-B (e.g. -bL), ``clush`` will enable a "live gathering" of results by line, so that the next line is displayed as soon as possible (e.g. when all nodes have sent the line)
162 -N disable labeling of command output
163 -P, --progress show progress during command execution; if writing is performed to standard input, the live progress indicator will display the global bandwidth of data written to the target nodes
164 -b, --dshbak display gathered results in a dshbak-like way (note: it will only try to aggregate the output of commands with same return codes)
165 -B like -b but including standard error
166 -r, --regroup fold nodeset using node groups
167 --axis=RANGESET for nD nodesets, fold the displayed nodeset (e.g. in gathered output headers) along provided axis only. Axes are indexed from 1 to n and can be specified here either using the rangeset syntax, e.g. '1', '1-2', '1,3', or by a single negative number meaning that the index is counted from the end. Because some nodesets may have several different dimensions, axis indices are silently truncated to fall in the allowed range. This is the per-invocation equivalent of the ``fold_axis`` library default.
168 -S, --maxrc return the largest of command return codes
169 --color=WHENCOLOR ``clush`` can use NO_COLOR, CLICOLOR and CLICOLOR_FORCE environment variables. NO_COLOR takes precedence over CLICOLOR_FORCE which takes precedence over CLICOLOR. When ``--color`` option is used these environment variables are not taken into account. ``--color`` tells whether to use ANSI colors to surround node or nodeset prefix/header with escape sequences to display them in color on the terminal. *WHENCOLOR* is ``never``, ``always`` or ``auto`` (which uses color if standard output/error refer to a terminal). Colors are set to [34m (blue foreground text) for stdout and [31m (red foreground text) for stderr, and cannot be modified.
170 --diff show diff between common outputs (find the best reference output by focusing on largest nodeset and also smaller command return code)
171 --outdir=OUTDIR output directory for stdout files (OPTIONAL)
172 --errdir=ERRDIR output directory for stderr files (OPTIONAL)
173
174 File copying:
175 -c, --copy copy local file or directory to remote nodes
176 --rcopy copy file or directory from remote nodes
177 --dest=DEST_PATH destination file or directory on the nodes
178 (optional: use the first source directory
179 path when not specified)
180 -p preserve modification times and modes
181
182 Connection options:
183 -f FANOUT, --fanout=FANOUT
184 do not execute more than FANOUT commands at the same time, useful to limit resource usage. In tree mode, the same *fanout* value is used on the head node and on each gateway (the *fanout* value is propagated). That is, if the *fanout* is **16**, each gateway will initiate up to **16** connections to their target nodes at the same time. Default *fanout* value is defined in ``clush.conf``\(5).
185 -l USER, --user=USER
186 execute remote command as user
187 -o OPTIONS, --options=OPTIONS
188 can be used to give ssh options, e.g. ``-o "-p 2022 -i ~/.ssh/myidrsa"``; these options are added first to ssh and override default ones
189 -t CONNECT_TIMEOUT, --connect_timeout=CONNECT_TIMEOUT
190 limit time to connect to a node
191 -u COMMAND_TIMEOUT, --command_timeout=COMMAND_TIMEOUT
192 limit time for command to run on the node
193 -m MODE, --mode=MODE
194 run mode; define MODEs in ``<confdir>/*.conf``
195 -R WORKER, --worker=WORKER
196 worker name to use for connection (``exec``, ``ssh``, ``rsh``, ``pdsh``, or the name of a Python worker module), default is ``ssh``
197 --remote=REMOTE whether to enable remote execution: in tree mode, 'yes' forces connections to the leaf nodes for execution, 'no' establishes connections up to the leaf parent nodes for execution (default is 'yes')
198
199 For a short explanation of these options, see ``-h, --help``.
200
201
202 EXIT STATUS
203 ===========
204
205 By default, an exit status of zero indicates success of the ``clush`` command
206 but gives no information about the remote commands exit status. However, when
207 the ``-S`` option is specified, the exit status of ``clush`` is the largest
208 value of the remote commands return codes.
209
210 For failed remote commands whose exit status is non-zero, and unless the
211 combination of options ``-qS`` is specified, ``clush`` displays messages
212 similar to:
213
214 :clush\: node[40-42]\: exited with exit code 1:
215
216
217 EXAMPLES
218 ===========
219
220 Remote parallel execution
221 -------------------------
222
223 :# clush -w node[3-5,62] uname -r:
224 Run command `uname -r` in parallel on nodes: node3, node4, node5 and node62
225
226 Local parallel execution
227 ------------------------
228
229 :# clush -w node[1-3] --worker=exec ping -c1 %host:
230 Run locally, in parallel, a ping command for nodes: node1, node2 and node3.
231 You may also use ``-R exec`` as the shorter and pdsh compatible option.
232
233 Display features
234 ----------------
235
236 :# clush -w node[3-5,62] -b uname -r:
237 Run command `uname -r` on nodes[3-5,62] and display gathered output results (integrated ``dshbak``-like).
238
239 :# clush -w node[3-5,62] -bL uname -r:
240 Line mode: run command `uname -r` on nodes[3-5,62] and display gathered output results without default header block.
241
242 :# ssh node32 find /etc/yum.repos.d -type f | clush -w node[40-42] -b xargs ls -l:
243 Search some files on node32 in /etc/yum.repos.d and use clush to list the matching ones on node[40-42], and use ``-b`` to display gathered results.
244
245 :# clush -w node[3-5,62] --diff dmidecode -s bios-version:
246 Run this Linux command to get BIOS version on nodes[3-5,62] and show version differences (if any).
247
248 :# clush -w dc[1-2]n[1-2] --axis=1 -b uname -r:
249 Gather output and fold the displayed nodeset header along axis 1 only, e.g. show ``dc[1-2]n1,dc[1-2]n2`` rather than ``dc[1-2]n[1-2]`` in the header block. See also ``fold_axis`` in the Library Defaults configuration to change it permanently.
250
251 All nodes
252 ---------
253
254 :# clush -a uname -r:
255 Run command `uname -r` on all cluster nodes, see ``groups.conf``\(5) to set up all cluster nodes (`all:` field).
256
257 :# clush -a -x node[5,7] uname -r:
258 Run command `uname -r` on all cluster nodes except on nodes node5 and node7.
259
260 :# clush -a --diff cat /some/file:
261 Run command `cat /some/file` on all cluster nodes and show differences (if any), line by line, between common outputs.
262
263 Node groups
264 -----------
265
266 :# clush -w @oss modprobe lustre:
267 Run command `modprobe lustre` on nodes from node group named `oss`, see ``groups.conf``\(5) to setup node groups (`map:` field).
268
269 :# clush -g oss modprobe lustre:
270 Same as previous example but using ``-g`` to avoid `@` group prefix.
271
272 :# clush -w @mds,@oss modprobe lustre:
273 You may specify several node groups by separating them with commas (please see EXTENDED PATTERNS in ``nodeset``\(1) and also ``groups.conf``\(5) for more information).
274
275
276 Copy files
277 ----------
278 :# clush -w node[3-5,62] --copy /etc/motd:
279 Copy local file `/etc/motd` to remote nodes node[3-5,62].
280
281 :# clush -w node[3-5,62] --copy /etc/motd --dest /tmp/motd2:
282 Copy local file `/etc/motd` to remote nodes node[3-5,62] at path `/tmp/motd2`.
283
284 :# clush -w node[3-5,62] -c /usr/share/doc/clustershell:
285 Recursively copy local directory `/usr/share/doc/clustershell` to the same
286 path on remote nodes node[3-5,62].
287
288 :# clush -w node[3-5,62] --rcopy /etc/motd --dest /tmp:
289 Copy `/etc/motd` from remote nodes node[3-5,62] to local `/tmp` directory, each file having their remote hostname appended, e.g. `/tmp/motd.node3`.
290
291 FILES
292 =====
293
294 *$CLUSTERSHELL_CFGDIR/clush.conf*
295 Global clush configuration file. If $CLUSTERSHELL_CFGDIR is not defined,
296 */etc/clustershell/clush.conf* is used instead.
297
298 *$XDG_CONFIG_HOME/clustershell/clush.conf*
299 User configuration file for clush. If $XDG_CONFIG_HOME is not defined,
300 *$HOME/.config/clustershell/clush.conf* is used instead.
301
302 *{sys.prefix}/etc/clustershell/clush.conf*
303 Configuration file when ClusterShell is installed in a Python virtual
304 environment.
305
306 *$HOME/.local/etc/clustershell/clush.conf*
307 Local user configuration file for clush (default installation for pip --user)
308
309 *~/.clush.conf*
310 Deprecated per-user clush configuration file (no longer read since
311 version 1.9).
312
313 *~/.clush_history*
314 File in which interactive ``clush`` command history is saved.
315
316 SEE ALSO
317 ========
318
319 ``clubak``\(1), ``cluset``\(1), ``nodeset``\(1), ``readline``\(3), ``clush.conf``\(5), ``groups.conf``\(5).
320
321 https://clustershell.readthedocs.io/
322
323 BUG REPORTS
324 ===========
325
326 Use the following URL to submit a bug report or feedback:
327 https://github.com/clustershell/clustershell/issues
328