A cross-platform command-line tool for executing jobs in parallel
A cross-platform command-line tool for executing jobs in parallel
rush is a tool similar to GNU parallel
and gargs.
rush borrows some idea from them and has some unique features,
e.g.,
supporting custom defined variables,
resuming multi-line commands,
more advanced embeded replacement strings.
These features make rush suitable for easily and flexibly parallelizing
complex workflows in fields like Bioinformatics (see examples).
Major:
--line-buffer in GNU parallel)-t), terminating the timed-out command and its child-process tree. (--timeout in GNU parallel)-r). (--retry-failed --joblog in GNU parallel)SIGINT/SIGKILL signals;
Windows uses Ctrl+C/Ctrl+Break followed by taskkill /T /F to terminate the process tree.-c). (--resume --joblog in GNU parallel,
sut it does not support multi-line commands, which are common in workflow)awk -v like custom defined variables (-v). (Using Shell variable in GNU parallel)-k). (Same -k/--keep-order in GNU parallel)-e): stop scheduling and clean up active child processes. (--halt 2 in GNU parallel)-D, default \n). (--recstart and --recend in GNU parallel)-n, default 1). (-n/--max-args in GNU parallel)-d, default \s+). (Same -d/--delimiter in GNU parallel){}, full data. (Same in GNU parallel){n}, nth field in delimiter-delimited data. (Same in GNU parallel){#}, job ID. With --continue, its saved form is stable when input order
changes. (Same replacement string as GNU parallel.){?}, threads per job, computed as max(1, CPUs / jobs). With --continue,
its saved form stays stable when the job count changes. (Not directly supported in GNU parallel){/}, dirname. ({//} in GNU parallel){%}, basename. ({/} in GNU parallel){.}, remove the last file extension. (Same in GNU parallel){:}, remove all file extensions (Not directly supported in GNU parallel){^suffix}, remove suffix (Not directly supported in GNU parallel){@regexp}, capture submatch using regular expression (Not directly supported in GNU parallel).
There's a limitation here: curly brackets can't be used in the regular expression.{%.}, {%:}, basename without extension{2.}, {2/}, {2%.}, manipulate nth field{file:}, {file:^_1}, remove all extensions of a preset variable (see below){{}}, {} itself{{1,}}, data containing double quotes {1,}.rush -v p={^suffix} 'echo {p}_new_suffix',
where {p} is replaced with {^suffix}. (Using Shell variable in GNU parallel)Minor:
--dry-run). (Same in GNU parallel)--trim). (Same in GNU parallel)--verbose). (Same in GNU parallel)Note that the comparison between rush and GNU parallel might be outdated, as both tools might have improved. See Differences between rush and GNU parallel on GNU parallel site.
Performance of rush is similar to gargs, and they are both slightly faster than parallel (Perl) and both slower than Rust parallel (discussion).
Note that speed is not the #.1 target, especially for processes that last long.
rush is implemented in Go programming language,
executable binary files for most popular operating systems are freely available
in release page.
Install conda, then run
conda install -c conda-forge rushOr use mamba, which is faster.
mamba install -c conda-forge rushrush v0.10.0
Tip: run rush -V to check update !!!
| OS | Arch | File, | Download Count |
|---|---|---|---|
| Linux | 32-bit | rush_linux_386.tar.gz | |
| Linux | 64-bit | rush_linux_amd64.tar.gz | |
| Linux | arm64 | rush_linux_arm64.tar.gz | |
| OS X | 64-bit | rush_darwin_amd64.tar.gz | |
| OS X | arm64 | rush_darwin_arm64.tar.gz | |
| Windows | 32-bit | rush_windows_386.exe.tar.gz | |
| Windows | 64-bit | rush_windows_amd64.exe.tar.gz | |
| Windows | arm64 | rush_windows_arm64.exe.tar.gz | |
| OpenBSD | 64-bit | rush_openbsd_amd64.tar.gz | |
| OpenBSD | arm64 | rush_openbsd_arm64.tar.gz | |
| FreeBSD | 64-bit | rush_freebsd_amd64.tar.gz | |
| FreeBSD | arm64 | rush_freebsd_arm64.tar.gz |
Just download compressed
executable file of your operating system,
and decompress it with tar -zxvf *.tar.gz command or other tools.
And then:
For Linux-like systems
If you have root privilege simply copy it to /usr/local/bin:
sudo cp rush /usr/local/bin/
Or copy to anywhere in the environment variable PATH:
mkdir -p $HOME/bin/; cp rush $HOME/bin/For windows, just copy rush.exe to C:\WINDOWS\system32.
go install github.com/shenwei356/rush@latest# download Go from https://go.dev/dl
wget https://go.dev/dl/go1.25.5.linux-amd64.tar.gz
tar -zxf go1.25.5.linux-amd64.tar.gz -C $HOME/
# or
# echo "export PATH=$PATH:$HOME/go/bin" >> ~/.bashrc
# source ~/.bashrc
export PATH=$PATH:$HOME/go/bin
git clone https://github.com/shenwei356/rush
cd rush
go build
# or statically-linked binary
CGO_ENABLED=0 go build -tags netgo -ldflags '-w -s'
# or cross compile for other operating systems and architectures
CGO_ENABLED=0 GOOS=openbsd GOARCH=amd64 go build -tags netgo -ldflags '-w -s'…Simple run, quoting is not necessary
# seq 1 3 | rush 'echo {}'
$ seq 1 3 | rush echo {}
3
1
2
Read data from file (-i)
$ rush echo {} -i data1.txt -i data2.txt
Keep output order (-k)
$ seq 1 3 | rush 'echo {}' -k
1
2
3
Timeout (-t)
$ time seq 1 | rush 'sleep 2; echo {}' -t 1
[ERRO] run command #1: sleep 2; echo 1: time out
real 0m1.010s
user 0m0.005s
sys 0m0.007s
Retry (-r)
$ seq 1 | rush 'python unexisted_script.py' -r 1
python: can't open file 'unexisted_script.py': [Errno 2] No such file or directory
[WARN] wait command: python unexisted_script.py: exit status 2
python: can't open file 'unexisted_script.py': [Errno 2] No such file or directory
[ERRO] wait command: python unexisted_script.py: exit status 2
Input containing {} (since v0.10.0)
$ echo "a attr{href}"="h4 text{}" | rush -T b -k -D "=" 'echo "{}"'
a attr{href}
h4 text{}
$ echo -ne "a{},b{{}},c{d}" | rush -D , -k "echo {}"
a{}
b{{}}
c{d}
Output {} itself (since v0.7.0)
$ echo abc | rush 'echo "{} {{}}"'
abc {}
Dirname ({/}) and basename ({%}) and remove custom suffix ({^suffix})
$ echo dir/file_1.txt.gz | rush 'echo {/} {%} {^_1.txt.gz}'
dir file_1.txt.gz dir/file
Get basename, and remove last ({.}) or any ({:}) extension
$ echo dir.d/file.txt.gz | rush 'echo {.} {:} {%.} {%:}'
dir.d/file.txt dir.d/file file.txt file
Job ID, combine fields index and other replacement strings
$ echo 12 file.txt dir/s_1.fq.gz | rush 'echo "job {#}: {2} {2.} {3%:^_1}"'
job 1: file.txt file s
Combine {#} with -c/--continue.
$ seq 5 | rush 'timNo open issues yet, or sync has not completed.