dongmu7335 2016-05-12 13:30
浏览 87
已采纳

由crontab运行的脚本不会生成数据

Using Cacti, I'm trying to run the following command:

php poller.php > test.cfg

As expected I'm getting the following output :

root@SLINUX01:[/usr/local/cacti]$tail -f test.cfg
Waiting on 1 of 1 pollers.
Waiting on 1 of 1 pollers.
Waiting on 1 of 1 pollers.
Waiting on 1 of 1 pollers.
05/12/2016 01:23:50 PM - POLLER: Poller[0] CACTI2RRD: /usr/bin/rrdtool update /usr/local/cacti/rra/stse01_traffic_in_14.rrd --template traffic_out:traffic_in 1463052230:2773678063:3900704413
05/12/2016 01:23:50 PM - POLLER: Poller[0] CACTI2RRD: /usr/bin/rrdtool update /usr/local/cacti/rra/stse01_traffic_in_15.rrd --template traffic_in:traffic_out 1463052230:1071486:1088742
05/12/2016 01:23:50 PM - SYSTEM STATS: Time:5.4128 Method:cmd.php Processes:1 Threads:N/A Hosts:3 HostsPerProcess:3 DataSources:9 RRDsProcessed:7
Loop  Time is: 5.41
Sleep Time is: 294.58
Total Time is: 5.42
^C

And my manipulated has updated.


Now using the crontab, I made the following :

*/5 * * * * cacti php /usr/local/cacti/poller.php > /home/cacti/test.cfg &>/home/cacti/test.cfg

But when i go in the /home/cacti/test.cfg after cron execution , I got nothing, but the cron runned the script :

May 12 15:25:01 SLINUX01 CROND[19871]: (root) CMD (cacti php /usr/local/cacti/poller.php > /home/cacti/test.cfg &>/home/cacti/test.cfg)

What is the source of this problem?

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • doulu4534 2016-05-12 13:41
    关注

    Your cron log entry only says that the command was tried. It does not guarantee that the command has been successfully started (permission problems? environment variables unset? unmounted filesystem?).
    Do you use the cron table for the same user that can successfully run the command from command-line?
    What are the exact paths when you run from command line?
    Note that in crontab you try to invoke php without giving its full path - that may well be the culprit.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 软件定义网络mininet和onos控制器问题
  • ¥15 微信小程序 用oss下载 aliyun-oss-sdk-6.18.0.min client报错
  • ¥15 ArcGIS批量裁剪
  • ¥15 labview程序设计
  • ¥15 为什么在配置Linux系统的时候执行脚本总是出现E: Failed to fetch http:L/cn.archive.ubuntu.com
  • ¥15 Cloudreve保存用户组存储空间大小时报错
  • ¥15 伪标签为什么不能作为弱监督语义分割的结果?
  • ¥15 编一个判断一个区间范围内的数字的个位数的立方和是否等于其本身的程序在输入第1组数据后卡住了(语言-c语言)
  • ¥15 Mac版Fiddler Everywhere4.0.1提示强制更新
  • ¥15 android 集成sentry上报时报错。