title: bash script for kill and re-run processes: not working properly
body: <p>I've crontab set like this</p>
  
  <pre><code>*/3 * * * * /usr/local/bin/checkHomeAssistant &gt;&gt; /dev/null 2&gt;&amp;1
  </code></pre>
  
  <p>where the checkHomeAssistant script check if the "shopList" process is on, otherwise I would like to close every process of chromium that are going and start the homeAssistant script.
  here is the code</p>
  
  <pre><code>#!/bin/bash
  
  #lo script che esegue nell’ambiente crontab (non X) deve sapere in che ambiente grafico deve agire e con quali variabili d’ambiente
  export DISPLAY=:0
  export XAUTHORITY=/home/pi/.Xauthority
  
  checkShopList=$(ps –ef | grep –v grep | grep –c shopList)
  checkChromium=$(ps –ef | grep –v grep | grep –c chromium-browser)
  
  if [ $checkShopList –eq 0 ]; then
   if [ $checkChromium –eq 1 ]; then
   pkill chromium
   sleep 5
   fi
   /home/pi/Desktop/homeAssistant
  fi
  </code></pre>
  
  <p>where the homeAssistant script is</p>
  
  <pre><code>    #!/bin/bash
  
  sleep 5
  
  /home/pi/Documents/QTProjects/shopList/build/ShopList &amp;
  chromium-browser --app=http://www.dakboard.com --start-maximized &amp;
  chromium-browser http://www.google.com --start-maximized &amp;
  #xvkbd -geometry 700x300 -compact minimizable $
  
  sleep 5
  
  wmctrl -r "DAKboard" -t 0
  wmctrl -r "MainWindow" -t 1
  wmctrl -r "Google - Chromium" -t 2
  
  wmctrl -s 0
  </code></pre>
  
  <p>my problem is that the checkHomeAssistant script messes up with the Killing of the chromium istances: not always all the istances are killed and sometimes it kills them later...
  suggestions?</p>