Reputation: 1553
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
Upvotes: 0
Views: 1049
Reputation: 229058
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 -l
in your cron script. And check the local mail, as cron output is normally sent there, there might be relevant error messages.
Is it related to pipe size as the result can be quite large?
No.
Upvotes: 3