Go Down

Topic: [solved] php-cli seems not to be executed by cron or Process (Read 768 times) previous topic - next topic


Jan 10, 2014, 05:45 pm Last Edit: Jan 10, 2014, 10:39 pm by ettore8 Reason: 1
Hi all,

i am going on with the development on the Arduino Yun platform....i decided to use php on the linux side and some bridge to communicate with the arduino. I need to start a php script on a specific event on the arduino and decided to use the Process class.

Code: [Select]

char binPath[17] = "/usr/bin/php-cli";
char scriptPath[37] = "/mnt/sda1/www/user/code/parsecan.php";
char inData[45];

Process execProc;

Piece of code of course is in between some if, while, ecc.
If i use instead of php-cli a simple "mkdir /root/test1" everything is perfect but as soon as i use php-cli, process is not executed on the linino.

The same happens if i try to start php-cli via crontab....

The strange is that if i execute php-cli directly from shell, everything run perfectly.

It seems to be a "linux problem" but i do not have clear idea on how to troubleshoot even if i am quite good on linux....

maybe have you already faced with this problem ?

Thank you


The solution was easy:

i added to the crontab entry the output redirection with
Code: [Select]

> /root/tmp.log 2>&1

and i have noticed that the problem was a relative path inside the php. php-cli will not execute the file in the same directory where it is stored.
So the new cron command should be:
Code: [Select]

cd /my/dir/path && php-cli myscript.php

For the Process class, i have tried to add the output redirection parameter but i was not able to get it working so i created a bash script with the cd command and the php-cli one. From Arduino i start the bash script....now it is working!


Go Up