开发者

Different result when executed from Crontab

开发者 https://www.devze.com 2023-02-07 02:23 出处:网络
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 behavi

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 si开发者_如何学运维ze 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 -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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号