1

I would like to run my bash my_script.sh using GNU parallel:

parallel < my_script.sh

where my_script.sh is:

command1 && command2
command3 
command4

Will command1 and command2 run in parallel or sequentially.
In case I am not clear:
command1
command2
command3
command4

or

command1 -> command2
command3
command4

?

Thank you!

aerijman
  • 2,522
  • 1
  • 22
  • 32

1 Answers1

0

&& lets you do something based on whether the previous command completed successfully.


It will run like this:

command1 -> command2 (only if the exit status of "command1" is zero)
command3
command4
Qmski
  • 26
  • 3
  • if I use semicolon instead of `&&`, will it run in parallel 1+2 - 3 - 4 ? – aerijman Oct 22 '20 at 20:52
  • 1
    @aerijman Please read this article, especially section "Brute Force" should resolve your doubts (if you want to execute each command parallel). [Get more done at the Linux command line with GNU Parallel](https://opensource.com/article/18/5/gnu-parallel). If you want to execute the command sequentially (line after line) use normal run: `./my_script.sh` – Qmski Oct 23 '20 at 05:39