0

I need to run more than one command in bash without waiting to finishing first one and starting other command. The commands can be like this inside bash file.

#!/bin/bash
perl test.pl -i file1 -o out1
perl test.pl -i file2 -o out2
and so on

All should run at the same time in different cores instead of running one after another.

SSh
  • 179
  • 2
  • 13
  • See http://www.gnu.org/software/bash/manual/bashref.html#Lists and read for "background". – Etan Reisner Oct 13 '15 at 16:58
  • 2
    Possible duplicate of [How do you run multiple programs from a bash script?](http://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-from-a-bash-script) – Cyrus Oct 13 '15 at 17:03

1 Answers1

2

Background them with &:

#!/bin/bash
perl test.pl -i file1 -o out1 &
perl test.pl -i file2 -o out2 &

Or better yet, use GNU parallel. This will allow you to use multiple CPUs and lots more.

A.P.
  • 146
  • 3