Run any cli command in concurrent mode. Choose how many threads you need (default: 5).
Run command with default params
./threadme -cmd "date +%s"
Output:
Command: [date +%s]
Job count to perform: [100]
Threads: [5]
Delay: 10 ms
Time limit for single worker: 60000 ms
--------------------------------------------------------------------------------
OUTPUT:[4/6] [date +%s] ==> [1650025517]
OUTPUT:[2/6] [date +%s] ==> [1650025517]
OUTPUT:[1/6] [date +%s] ==> [1650025517]
OUTPUT:[3/6] [date +%s] ==> [1650025517]
...
Use param {{N}}
to use job number.
./threadme -cmd 'wc -l {{N}}.txt'
Output:
[4/10] [wc -l 4.txt] ==> [3 4.txt]
ERROR: [2/10] [wc -l 2.txt] ==> [wc: 2.txt: No such file or directory; exit status 1;]
ERROR: [6/10] [wc -l 6.txt] ==> [wc: 6.txt: No such file or directory; exit status 1;]
[7/10] [wc -l 7.txt] ==> [1 7.txt]
ERROR: [8/10] [wc -l 8.txt] ==> [wc: 8.txt: No such file or directory; exit status 1;]
...
Use param {{LINE}}
to use job param from file.
./threadme -cmd 'bash sendmail.sh {{LINE}}' -f customers.txt
Output:
[0/8256] [bash sendmail.sh [email protected]] ==> [Sent: [email protected]]
ERROR: [4/8256] [bash sendmail.sh [email protected]] ==> [Invalid user; exit status 1;]
[2/8256] [bash sendmail.sh [email protected]] ==> [Sent: [email protected]]
[1/8256] [bash sendmail.sh [email protected]] ==> [Sent: [email protected]]
[3/8256] [bash sendmail.sh [email protected]] ==> [Sent: [email protected]]
...
Use -stop-on
flag to halt all tasks upon encountering an error message.
Note: All tasks will be discontinued if any job yields a message indicating a stop condition.
./threadme -cmd 'bash sendmail.sh {{LINE}}' -f customers.txt -stop-on 'Error:'
Output:
[0/8256] [bash sendmail.sh [email protected]] ==> [Sent: [email protected]]
ERROR: [4/8256] [bash sendmail.sh [email protected]] ==> [Invalid user; exit status 1;]
[2/8256] [bash sendmail.sh [email protected]] ==> [Sent: [email protected]]
[1/8256] [bash sendmail.sh [email protected]] ==> [Sent: [email protected]]
[3/8256] [bash sendmail.sh [email protected]] ==> [Sent: [email protected]]
[4/8256] [bash sendmail.sh [email protected]] ==> [Error: timeout while sending [email protected]]
> Stop output message found: Error: timeout while sending [email protected]
> Stopping all workers!
> Duration: 12.03473712s
Use -while
flag to cease all tasks when a success message is absent from any of the jobs.
Note: All jobs will be terminated if the message differs for even a single job.
./threadme -cmd 'bash sendmail.sh {{LINE}}' -f customers.txt -while 'Sent:'
Output:
[0/8256] [bash sendmail.sh [email protected]] ==> [Sent: [email protected]]
ERROR: [4/8256] [bash sendmail.sh [email protected]] ==> [Invalid user; exit status 1;]
> No `while message` found: Invalid user; exit status 1;
> Stopping all workers!
> Duration: 7.03404163s
Use -interpreter
flag to change command interpreter. By default it's from variable$SHELL
.
# `/bin/bash`
./threadme -cmd 'echo "$USER $RANDOM"' -n=1
# [0/1] [echo $USER $RANDOM] ==> [bobiverse 31459]
./threadme -cmd 'echo "$USER $RANDOM"' -n=1 -interpreter=/bin/sh
# [0/1] [echo $USER $RANDOM] ==> [bobiverse]