title: Start lots of background jobs but keep their logs separated
body: <p>I have little experiences in shell commands in unix.
  So far, I have checked stackOverflow and know how to run simple shell scripts in order by</p>
  <ol>
  <li>using echo</li>
  </ol>
  <pre><code>echo $(sh dosomthing1.sh)
  echo $(sh dosomthing2.sh)
  </code></pre>
  <ol start="2">
  <li>directly using sh xxx and wait</li>
  </ol>
  <pre><code>sh dosomthing1.sh
  wait 
  sh dosomthing2.sh
  </code></pre>
  <ol start="3">
  <li>using &amp;&amp;</li>
  </ol>
  <pre><code>sh dosomthing1.sh &amp;&amp; sh dosomthing2.sh
  </code></pre>
  <p>But these ways seem to be helpless to solve my problem...</p>
  <p>Here is my problem:</p>
  <p>I have a basic shell script to do a maven compile and then using &quot;nohup xxx &amp;&quot; to start a java application in background. the script is shown below:</p>
  <pre><code>#get the input env parameter
  env=$1
  
  #goto application root directory
  cd /applicationDir
  
  #to compile
  mvn install -Dmaven.test.skip=true
  
  #to start with parameter env
  nohup java -jar -Dspring.profiles.active=$env myApplication.jar &amp;
  
  #to tail the log
  tail -20f myApplication.log
  </code></pre>
  <p>I have too many different applications with the same startup scripts and it is hard to start them one by one. I need to start them with one command.</p>
  <p>All the shell scripts are expected to be processed one by one in order. If there are any exceptions, skip  and run the next one.</p>
  <p>And when I tried to write a script like this:</p>
  <pre><code>sh start1.sh
  wait
  echo &quot;application 1 was start up&quot;
  
  sh start2.sh
  wait
  echo &quot;application 2 was start up&quot;
  
  ...
  
  sh startxxx.sh
  wait
  echo &quot;application xxx was start up&quot;
  
  </code></pre>
  <p>Though all the children shell scripts will process in order as what I expected, and the output infomations looked like the shell is functioning well, but the fact is only the last application will be started, all the previous command &quot;nohup xxxx &amp;&quot; will be shut down.</p>
  <p>Also I have tried to write like this:</p>
  <pre><code>sh start1.sh &amp;
  
  sh start2.sh &amp;
  
  ...
  
  sh startxxx.sh &amp;
  </code></pre>
  <p>Although the result was what I want, all the application will be started well, but during processing the scripts, because of the parallel running of the scripts, the consoled output is unreadable. It comes to a good result but not a graceful way.</p>
  <p>I have no idea how to solve this problem...</p>
  <p>Please help me with this, thank you very much!</p>