I am trying to get the number of open files periodically through crontab using lsof|wc -l.
It always returns zero. It is giving correct result when i run it directly.Any idea about this strange behaviour?Is it related to pipe size as the result can be quite large?Thanks a lot.
Kaka
The main difference is the environment variables.
In this case it might be the PATH. lsof is often found in or /usr/sbin , that might be in your PATH when you run it interactivly, while not in the PATH when run from cron.
try
/usr/sbin/lsof|wc -lin your cron script. And check the local mail, as cron output is normally sent there, there might be relevant error messages.No.