title: if statement not working in cron
body: <p>I have the following code: (record.sh)</p>
  
  <pre><code>cd $(dirname $0)
  
  dt=$(date '+%d/%m/%Y %H:%M:%S');
  echo $dt;
  read action &lt; /home/nfs/sauger/web/pi/action.txt
  echo $action;
  if [[ $action == *"start"* ]]
  then
    echo "start recording"
    ./gone.sh
    exit 1
  elif [[ $action == *"stop"* ]]
  then
   echo "stop recording"
    ./gone.sh
    exit 1
  else 
  #More stuff done here
  fi
  </code></pre>
  
  <p>When I run this script manually the output is the following:</p>
  
  <pre><code>19/01/2016 19:07:11
  start
  start recording
  </code></pre>
  
  <p>If the same script is run via a (root) cronjob, the output is the following:</p>
  
  <pre><code>19/01/2016 19:07:01
  start
  </code></pre>
  
  <p>As you can see, the file "action.txt" has been read without a problem ("start" is logged both times) so this should not be an issue of permissions or wrong paths. But when run as a cronjob, the if-statement is not called. No "start recording" appears.</p>
  
  <p>So my question is: Why does the if-statement work when I call the script manually, but not when this is done via cron?</p>