title: Parallel processing with bash '&' command
body: <p>I am trying to run a single R file multiple times at the same time with different arguments. <code>GNU Parallel</code> is not an option for me because I am running this on a server where I'm not authorized to install Parallel. So I chose the bash command &amp;.</p>
  
  <pre><code>command1 &amp; command2 &amp; command3 ..... command30
  </code></pre>
  
  <p>However, when I run this, it is not behaving as expected. In the commands I am saving the output of each command to a new file and I notice that some of the files are empty. Actually most of them. So I'm guessing by only writing the above, some of the processes are being killed.</p>
  
  <p>However, when I give </p>
  
  <pre><code>command1 &amp;
  command2 &amp;
  command3 &amp;
  command4 &amp;
  
  wait &amp;
  
  command5 &amp;
  command6 &amp;
  command7 &amp;
  command8 &amp;
  
  wait 
  
  .
  .
  .
  </code></pre>
  
  <p>It works fine, but the problem is it takes almost 5 time more time than running only <code>command1</code> because it waits till the previous commands are finished. Time is very important factor here and I want all the commands to run in the same time (almost) as it would take for just one command.</p>
  
  <ul>
  <li>Why is this happening that without <code>wait</code> it "crashes"?  </li>
  <li>Is there any way I can improve the time so that all the commands can run at the time taken by only one command? </li>
  <li>Is there any way I can implement this without using <code>wait</code>?</li>
  </ul>
  
  <p>(Technically I know <code>&amp;</code> doesn't make processes run in parallel but it creates a different processes for every command).</p>
  
  <p>Thanks in advance!</p>
  
  <p>My original code:</p>
  
  <pre><code>Rscript svmRScript_v2.r 0.05 1 &gt; output/out0.1-10.txt &amp;
  Rscript svmRScript_v2.r 0.05 2 &gt; output/out0.05-2.txt &amp;
  Rscript svmRScript_v2.r 0.05 5 &gt; output/out0.05-5.txt &amp;
  Rscript svmRScript_v2.r 0.05 10 &gt; output/out0.05-10.txt &amp;
  
  wait &amp;
  
  Rscript svmRScript_v2.r 0.05 50 &gt; output/out0.05-50.txt &amp;
  Rscript svmRScript_v2.r 0.05 100 &gt; output/out0.05-100.txt &amp;
  Rscript svmRScript_v2.r 0.05 500 &gt; output/out0.05-500.txt &amp;
  Rscript svmRScript_v2.r 0.01 1 &gt; output/out0.1-10.txt &amp;
  
  wait &amp;
  
  Rscript svmRScript_v2.r 0.01 2 &gt; output/out0.01-2.txt &amp;
  Rscript svmRScript_v2.r 0.01 5 &gt; output/out0.01-5.txt &amp;
  Rscript svmRScript_v2.r 0.01 10 &gt; output/out0.01-10.txt &amp;
  Rscript svmRScript_v2.r 0.01 50 &gt; output/out0.01-50.txt &amp;
  
  wait &amp;
  
  Rscript svmRScript_v2.r 0.01 100 &gt; output/out0.01-100.txt &amp;
  Rscript svmRScript_v2.r 0.01 500 &gt; output/out0.01-500.txt &amp;
  Rscript svmRScript_v2.r 0.005 1 &gt; output/out0.1-10.txt &amp;
  Rscript svmRScript_v2.r 0.005 2 &gt; output/out0.005-2.txt
  </code></pre>