title: Script with lsof works well on shell not on cron
body: <p>I have a small script do count open files on Linux an save results into a flat file. I intend to run it on Cron every minute to gather results later. Script follows:</p>
  
  <pre><code>/bin/echo "Timestamp: ` date +"%m-%d-%y %T"` Files: `lsof | grep app | wc -l`"
  </code></pre>
  
  <p>And the crontab is this: </p>
  
  <pre><code>*/1 * * * * /usr/local/monitor/appmon.sh &gt;&gt; /usr/local/monitor/app_stat.txt
  </code></pre>
  
  <p>If I run from shell ./script.sh it works well and outputs as:</p>
  
  <pre><code>Timestamp: 01-31-13 09:33:59 Files: 57
  </code></pre>
  
  <p>But on the Cron output is:</p>
  
  <pre><code>Timestamp: 01-31-13 09:33:59 Files: 0
  </code></pre>
  
  <p>Not sure if any permissions are needed or similar. I have tried with sudo on lsof  without luck as well.</p>
  
  <p>Any hints?</p>