Name

psh — run a command on or copy a file to multiple nodes.

Synopsis

psh [ OPTIONS ] [ command [ args ] ]

psh [ OPTIONS ] [ -s ] [ files | directories ]

Description

psh runs a command on all or a group of nodes. The output of each command is parsed and common parts are only shown once.

With the option -s or -sync, one or more file(s) and/or entire directories (including subdirectories) are synchronized (copied) to the selected nodes.

Global options

-c, -configfile file

Define a group and a configuration file to use. The file is looked up in the current directory.

-g, -group group

Use nodes and other parameters in group group, defined in the configuration file ~/.psh.d/group. This is short for of -c ~/.psh.d/group.

-n, -node nodelist

Add nodes nodelist to the list of nodes.

-x, -xnode nodelist

Exclude nodes nodelist from the list of nodes.

-rcmd command

Use command command to start up a remote command. Command could be pssh (default), rsh or ssh.

-diff command

Use command command to parse and compare the command output. Default is diff -q.

-autocd path

Change to directory path on each node before running the command or copying the file. Default is ${PWD/${HOME}/~}. Use an empty path ("") to disable changing to a directory first.

-v

Be verbose.

-h

Show a help message.

Without option -g or option -c, a default file named like the current hostname, the current hostname without trailing numerical characters ([0-9]*), or default (in this order) within ~/.psh.d/ is used. If none of this files is found, an empty template file ~/.psh.d/default is created. This file may be modified to fit your needs!

Nodelist is a comma separated list of node names. The list can be abbreviated to node-[from-to], e.g. node-[003-115,001] will be expanded to node-001, node-003, node-004, ..., node-115.

Examples

This example shows a configuration file ~/.psh.d/rack1 defining nodes node-01 up to node-16 within rack number 1:

  ## psh defaults for rack 1
  ## uncomment all options you need...

  ## default nodelist:
  # node nodename[01-16]
  node node-[01-16]

  ## default remote command:
  # rcmd ssh -x

  ## don't start more than 1 remote shell at the same time?
  # max 1

  ## be always verbose ?
  # verbose 

To see the uptime of all nodes in rack 1, execute

  # psh -g rack1 uptime

In order to compare the current date on all nodes, run date on all nodes:

  # psh date
  === node-[01-04,06-16]
  Mon Jul 18 12:45:17 CEST 2005
  === node-05
  Mon Jul 18 12:45:18 CEST 2005
    

To calculate and compare the md5sum of all Linux kernels on all but node node-03, execute:

  # psh -x node-03 md5sum /boot/vmlinux
  === node-[01,02,04,06-16]
  c9c0728c41ca03a9ee9982869e28216e  /boot/vmlinuz
  === node-05
  ff62b57a078f1f8244796c5609a053e8  /boot/vmlinuz

To copy the file /etc/hosts to all nodes, execute:

  # psh -sync /etc/hosts
  Prepare files for distribution:
  /tmp/pshout.1235 /etc/hosts
  Continue (y/n)?[n] 

(Presuming a suitable configuration file within ~/.psh.d is found.)

Note

The local file /etc/hosts is also replaced by a copy of this file.

To copy the file /etc/hosts to all but the local node, execute:

  # psh -s -x `hostname` /etc/hosts
  Prepare files for distribution:
  /tmp/pshout.1236 /etc/hosts
  Continue (y/n)?[n] 

Files

~/.psh.d/*

Configuration files for different groups.

See also

pssh(8) and psmstart(8).