title: Bash scripting, based on hostname and a given time wait until that time and then continue
body: <p>I have a cluster with multiple linux servers (6) and IBM Websphere Application Server is running on that.
  These IBM Websphere Application Servers needs to be started up in a specific order, first server1, then server2 etc.</p>
  <p>Currently I have a script that will stop and start the IBM Websphere Application Server when I stop or start the linux server itself.</p>
  <p>Now I want to build in that script that it will check what day it is, and biased on the hostname it waits until a specific time, for example:</p>
  <ul>
  <li>server1, needs to check that if it is a Sunday, and hostname is server1 it needs to wait until 2:00 AM then it will execute</li>
  <li>server2, needs to check that if it is a Sunday, and hostname is server2 it needs to wait until 2:30 AM then it will execute</li>
  <li>server3, needs to check that if it is a Sunday, and hostname is server3 it needs to wait until 3:00 AM then it will execute</li>
  </ul>
  <p>My issue is how do I code that wait until a specific time?
  If have the following to check about the day and hostname:</p>
  <pre><code>DOW=$(date +&quot;%a&quot;)
  if [ $DOW = &quot;Sun&quot; ] then
  if [ $HOSTNAME = server1 ] then
  wait until 2:00 AM
  and then continue with this
          cat $WAS_TEMP/nodeagent.startup | while read NODE
          do
                  echo &quot;Start Nodeagent&quot;
                  /opt/ws/profiles/$NODE/bin/startNode.sh &gt; /dev/null &amp;
                  sleep 45
          done
  
  if [ $HOSTNAME = server2 ] then
  wait until 2:30 AM
  and then continue with this
          cat $WAS_TEMP/nodeagent.startup | while read NODE
          do
                  echo &quot;Start Nodeagent&quot;
                  /opt/ws/profiles/$NODE/bin/startNode.sh &gt; /dev/null &amp;
                  sleep 45
          done
  if [ $HOSTNAME = server3 ] then
  wait until 3:00 AM
  and then continue with this
          cat $WAS_TEMP/nodeagent.startup | while read NODE
          do
                  echo &quot;Start Nodeagent&quot;
                  /opt/ws/profiles/$NODE/bin/startNode.sh &gt; /dev/null &amp;
                  sleep 45
          done
  fi
  </code></pre>
  <p>It has to be done in the script itself so no crontab.</p>