toolbox

thread
Login

Execute commands in parallel on a collection of hosts

Download

thread

Usage

$ thread -h
Execute commands in parallel on a collection of hosts
Usage:
	thread [ -i <hosts> ] [ -n <nthreads> ] cmd
Options:
	-h        : display this help and exit
	-i <file> : list of hosts
	-n <uint> : number of concurrent threads (10 by default)

Example

Build a list of hosts to deal with:

$ cat > hosts
host1
host2
host3
^D

Then execute a command on these hosts using thread. The "HOST" pattern in the command line is replaced by the name of the current host the command is running on:

$ thread -i hosts ssh HOST uptime
host1 >  10:32:12 up  3 days, 10:45,  2 users,  load average: 0.22, 0.16, 0.16
host2 >  17:02:44 up 24 days, 18:35,  4 users,  load average: 0.34, 0.24, 0.24
host3 >  16:12:54 up  8 days, 13:05,  7 users,  load average: 0.47, 0.34, 0.38