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:
/bin/echo "Timestamp: ` date +"%m-%d-%y %T"` Files: `lsof | grep app | wc -l`"
And the crontab is this:
*/1 * * * * /usr/local/monitor/appmon.sh >> /usr/local/monitor/app_stat.txt
If I run from shell ./script.sh it works well and outputs as:
Timestamp: 01-31-13 09:33:59 Files: 57
But on the Cron output is:
Timestamp: 01-31-13 09:33:59 Files: 0
Not sure if any permissions are needed or similar. I have tried with sudo on lsof without luck as well.
Any hints?