upsforum

Well-Known Member
Jul 27, 2005
473
0
166
I have a vps with suPHP, suhosin and PDO library installed, I need of run a php script in crontab with # php cli modality. It work from webserver (http) and from console (#php -q /path/..../script.php) but with cron it not work.

The problem is that with crontab I get an not found error of PDO class:

<b>Fatal error</b>: Class 'PDO' not found in <b>/home/user/public_html/test/lib/common/class.PdoWrapper.php</b> on line <b>42</b><br />

If think that problem is of crontab PATH that it not match PDO class library but I dont understand like I can resolve it
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
What is the exact cron command being used in the crontab? Next, what is line 42 in the /home/user/public_html/test/lib/common/class.PdoWrapper.php file?
 

upsforum

Well-Known Member
Jul 27, 2005
473
0
166
I use ...* * * php -q /path/..../script.php

... and I tried with ... * * * /usr/local/bin/php -q /path/..../script.php , in this situation PDO work fine but I get some errors of "file not found" because in script.php the files are include with rel path ("./.......") and not full path ("/home/....")
I should put the full path and use second command? I wanted to avoid this change.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Please put the full path to the script yes. You cannot truncate the path to the script in that manner for a cronjob entry. Cron jobs do not allow relative paths of this sort.

Also, when the cron command is asked going forward, please do not use examples and provide the actual command used. By shortening it and using examples, it is nearly impossible to know what you had actually used. You can certainly hide the username by putting username in the path, but any other part of the path would need to be the real value being used.
 

upsforum

Well-Known Member
Jul 27, 2005
473
0
166
sorry you're right,

1) first solution

* * * * * php -q /home/username/public_html/test/scarico/scarica_trasf_Ordini.php

I get PDO class not found error

2) second solution

/usr/local/bin/php -q /home/username/public_html/test/scarico/scarica_trasf_Ordini.php

I dont get error PDO class but I get errors for include of others file with relative path ("../include/otherfile.php)
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Could you try /usr/bin/php and let us know the results when you use that path?

If that doesn't work, then the other files being included would need to have the full path's used instead unfortunately.