phpcroncactipoller

Script runned by crontab will no produce data


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.


Solution

  • 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.