I have read the example at http://www.gnu.org/software/parallel/man.html#example__calling_bash_functions however, is it possible to use gnu parallel to call 2 functions which do not have any variables you pass to them ?
example
a() {
echo "download a"
wget fileA
}
b() {
echo "download b"
wget fileB
}
and use parallel to call both functions a
& b
?
Logical OR Operator ( || ) in Bash It is usually used with boolean values and returns a boolean value. It returns true if at least one of the operands is true. Returns false if all values are false.
In case you need to execute several processes in batches, or in chunks, you can use the shell builtin command called "wait". See below. The first three commands wget commands will be executed in parallel. "wait" will make the script wait till those 3 gets finished.
Run them in background. And then wait for them to complete.
a() {
echo "download a"
wget fileA
}
b() {
echo "download b"
wget fileB
}
a &
b &
wait # waits for all background processes to complete
If you insist on using GNU Parallel:
a() {
echo "download a"
wget fileA
}
b() {
echo "download b"
wget fileB
}
export -f a
export -f b
parallel ::: a b
If you need read access to variables in the shell you can either export the variables or use env_parallel
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With