title: Shell script isn't working correctly on crontab, works when manually called
body: <p>I've got a script in sh under Solaris 5.8 that isn't working as expected and don't really know why...</p>
  
  <p>The script reads a list of URLs from a file, tests them with curl and writes the output to a log file:</p>
  
  <pre><code>#!/bin/sh
  
  # Logs path
  LOG_DIR=/somedir/logs
  
  # URLs file path
  URL_FILE=/somedir/url
  
  # Actual date
  DATE=`date +%Y%m%d%H%M`
  
  # CURL
  CURL=/somedir/bin/curl
  
  test_url()
  {
      cat $URL_FILE | grep -i $1 | while read line
      do
          NAME=`echo $line | awk '{ print $1 }'`
          URL=`echo $line | awk '{ print $2 }'`
          TIME=`$CURL -s -o /dev/null -w %{time_total} $URL`
          echo "$DATE $TIME" &gt;&gt; $LOG_DIR/${NAME}_${1}.log
      done
  }
  
  test_url someurl
  test_url someotherurl
  </code></pre>
  
  <p>The URL_FILE has this layout:</p>
  
  <pre><code>somename1 http://someurl/test
  somename2 http://someotherurl/test
  </code></pre>
  
  <p>The script loads the URLs from the file and then uses curl to get the total time the URL takes to load, then prints the date and the time (in ms). The problem I find is that the variable <code>TIME</code> doesn't work when called inside a crontab, but it does when called with the user itself:</p>
  
  <pre><code># Output when called with the user ./script.sh
  201202201018 0.035
  # Output when called from crontab.
  201202201019
  </code></pre>
  
  <p>If I redirect all output <code>* * * * * /path/to/script/script.sh 1&amp;2 &gt; /tmp/output</code>, the output file is blank.</p>
  
  <p>Also I haven't been able to see any output in /var/log/syslog about it. Any clue why <code>TIME</code> variable isn't displaying correctly when called via crontab?</p>