title: Issue in a Bash loop
body: <p>just a quick question with something I'm not understanding.  Everything is working fine - I'm just trying to get my head around something.</p>
  
  <p>I have a very simple Bash script that is restarting dnsmasq once per day:</p>
  
  <pre><code>LogFile="/var/log/logfile"
  declare -a CMD_AR=()
  declare -a ECHO_OUT=(stopping starting)
  STOP=$(service dnsmasq \stop)
  SLEEP=$(\sleep 15)
  START=$(service dnsmasq \start)
  CMD_AR+=($STOP)
  CMD_AR+=($START)
  
  z=0
  while [[ $z -le 1 ]]; do
        DT=`date +%c`
        echo "$DT - ${ECHO_OUT[$z]} dnsmasq..." &gt;&gt; ${LogFile}
        eval ${CMD_AR[$z]} &gt;&gt; ${LogFile} 2&gt;&amp;1
        unset DT
        eval ${SLEEP}
        z=$[$z+1]
  done
  </code></pre>
  
  <p>So...this works, however, the DT variable never changes.  So my log file reads:</p>
  
  <pre><code>Tue 31 Oct 2017 10:57:07 PM MDT - stopping dnmasq
  Tue 31 Oct 2017 10:57:07 PM MDT - starting dnmasq
  </code></pre>
  
  <p>Shouldn't the time string be at least 15 (the value of sleep 15) seconds different?  I'm failing to understand why the loop is not re-computing the DT variable - anyone?</p>
  
  <p>Also, I'll take any suggestions on my code as well - I'm a total hack when it comes to scripting.</p>