title: Bash wait until finishing the job and execute the next command
body: <p>I have a problem with my bash script:</p>
  
  <pre><code>cmd1='/usr/bin/wget http://mysite/folder/'
  $cmd1 &gt; "/var/www/html/log/data.log" 2&gt;&amp;1 &amp; 
  
  cmd2='/usr/bin/indexer --rotate --all' 
  $cmd2 &gt; "/var/www/html/log/$(date +%Y-%m-%d_%H:%M)" 2&gt;&amp;1 &amp; 
  </code></pre>
  
  <p>Getting the data by wget takes much time, but next command executes before wget finishes the job.</p>
  
  <p>How can I check if wget has been finished and execute the next command.
  Thanks!</p>
  
  <p>P.S: I have tried to use sleep between these commands and the second command executes multiple times. I need just once. </p>