Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
February 09, 2012, 03:57:15 PM

Pages: [1]   Go Down
  Print  
Author Topic: I need cron to use php 5 not 4!  (Read 1779 times)
ZenCoder
Space Explorer
***
Offline Offline

Posts: 6


« on: November 29, 2007, 05:27:08 PM »

My (Drupal) website requires regularly scheduled execution of a php file (cron.php) to peform a variety of maintenance tasks.

So I setup a cron task
Code:
[tt][tt]php /home/neotaku2/public_html/integration/cron.php
[/tt][/tt]

Then I added a module that either requires php 4 with support for "domxml_open_mem()", or php 5.

So I use cPanel to switch to PHP 5.

Unfortunately the switch works via a .htaccess file, so my cron task is still running via PHP 4 and it crashes...

<b>Fatal error</b>:  Call to undefined function:  domxml_open_mem()

So I change the cron task to open the same file with php 5....

/usr/local/php5/bin/php /home/neotaku2/public_html/integration/cron.php

Only now I get

Warning: include_once(./includes/bootstrap.inc): failed to open stream: No such file or directory in /home/neotaku2/public_html/integration/cron.php on line 9

Warning: include_once(): Failed opening './includes/bootstrap.inc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/neotaku2/public_html/integration/cron.php on line 9

Fatal error: Call to undefined function  drupal_bootstrap() in /home/neotaku2/public_html/integration/cron.php on line 10


Either way I can no longer update the site via cron.

Can anyone explain what I am doing wrong here?




Logged
MrPhil
Berserker Poster
*****
Offline Offline

Posts: 5083



« Reply #1 on: November 29, 2007, 06:14:16 PM »

Is ./includes/bootstrap.inc supposed to be a system (PHP) file, or is it a Drupal file? Is there any reason to believe that you might be executing in a different directory than before?

I see the PHP include path is still pointing to PHP 4 libraries (/usr/lib/php and /usr/local/lib/php). I think there's either a php.ini command line or a line to put in cron.php (ini_set('include_path','.:/usr/local/php5/lib/php'); or something similar) to set a new include path -- sorry, I don't what should be in the path -- you'll have to research where PHP 5 needs to look for this stuff. No guarantee that this will solve the problem, as I don't know if the include path gets involved if you specify a path starting with ".".
Logged

ZenCoder
Space Explorer
***
Offline Offline

Posts: 6


« Reply #2 on: November 29, 2007, 07:33:53 PM »

Those are Drupal files, they are required by every page on a Drupal site.
cron.php is a Drupal generated/maintained file, editing it is not an option.
The paths are relative to the location of the cron.php file.
There is only one cron.php file so the same one is being executed.

The normal method is to set cron to open open the page via wget or lynx, but that is disabled at lunarpages.

For some reason "php ..." can open the included files and "/usr/local/php5/bin/php cannot ..."

The permissions for the included files are the same as for cron.php (755)

Currently I have the module that requires php 5 disabled.

cron.php works via the web browser under php4 and php5 and calling php via cron works as well.

I just can't figure out how to use php 5 via cron. Sad

---
I created a file that calls phpinfo() and executed it under php 5

Via browser ...


Configuration File (php.ini) Path    /usr/local/etc/php5/cgi
Loaded Configuration File    /usr/local/etc/php5/cgi/php.ini
include_path   .:/usr/lib/php:/usr/local/lib/php
open_basedir   '.:/proc/uptime:/tmp:/home:/usr/local/lib/php:/usr/home:/usr/local/bin/'

Via Cron ...

Configuration File (php.ini) Path => /usr/local/etc/php5/cgi
Loaded Configuration File => /usr/local/etc/php5/cgi/php.ini
include_path => .:/usr/lib/php:/usr/local/lib/php
open_basedir => '.:/proc/uptime:/tmp:/home:/usr/local/lib/php:/usr/home:/usr/local/bin/'

Those settings are the same, I am not sure what other settings would be relevant.

UPDATE:

When I  use the "php" command,  phpinfo() returns HTML and reports a Server API value of "CGI"
When I use "usr/local/php5/bin/php", phpinfo() returns plain text and reports a Servver API value of "Command Line"

I have no if CGI vs Command line is making a difference here or if so how to correct it.



« Last Edit: November 29, 2007, 08:11:26 PM by ZenCoder » Logged
yzerman
Trekkie
**
Offline Offline

Posts: 10


« Reply #3 on: November 30, 2007, 06:11:45 AM »

you need to set absolute paths in the cron.php file. It warns you where its looking for the file - so change the include statement to be include('/home/blah/blah/yourfile.php'); and not just include('yourfile.php');
Logged
Alberonn
Spacescooter Operator
*****
Offline Offline

Posts: 41



WWW
« Reply #4 on: November 30, 2007, 08:14:48 AM »

You say you can't use wget or lynx, but have you tried curl? I've used Drupal and I found that for my cron
Code:
curl -s http://yoursite.com/integration/cron.php
worked the best.
Logged
JeremyD
SleePy...
Jabba the Hutt
*****
Offline Offline

Posts: 735

SMF Team Member


WWW
« Reply #5 on: November 30, 2007, 09:42:08 AM »

to run it as php5 you need to use the specific path to php5

I don't know where it is on shared servers since I used a dedicated server and only run php5, But I do run multiple php versions on my own machine. So when I want to run a script as php6 I do /home/php6/bin/php /home/test/public_html/script.php
Again I don't know where php is compiled on shared servers since they can be different. But a php info page would tell us.

Look at the configure command. It should have a prefix on it.

Logged

ZenCoder
Space Explorer
***
Offline Offline

Posts: 6


« Reply #6 on: November 30, 2007, 11:38:51 AM »

Thanks
--
I have the path to php5 which I tested with phpinfo().  gs.
--
My temporary solution was to create a cronhelper.php <code><? $f = file("http://......com/cron.php"); ?></code>.  That way I am using php 4 to request a page that gets processed with php 5.
--
I just tried curl as suggested and it works as well
--

So I have a work around in place, but I still would like to learn why php5 is failing to open the included files, and fix the problem if possible.

Unfortunately I only learned enough about installing & configuring php to get my personal test servers working.

<code> /usr/local/php5/bin/php /.../whatever.php </code>  is running in command line mode
<code>php /.../whatever.php </code> is running in CGI mode

I am not sure if that is the difference that prevents php 5 from opening included files or not.  All the other settings that I know to check are the same.

Any suggestions on what to look for?
Logged
JeremyD
SleePy...
Jabba the Hutt
*****
Offline Offline

Posts: 735

SMF Team Member


WWW
« Reply #7 on: November 30, 2007, 06:53:01 PM »

How are you opening files? Are you using relative paths?
These may fail since the direcotry would be from our /home/cpanelname it is loading from. This is why you should use full paths.
Logged

lexhair
Galactic Royalty
*****
Offline Offline

Posts: 402


« Reply #8 on: December 06, 2007, 12:25:29 PM »

You say you can't use wget or lynx, but have you tried curl? I've used Drupal and I found that for my cron
Code:
curl -s http://yoursite.com/integration/cron.php
worked the best.
How do you get the cURL call to output to the 'bit bucket?'
Logged
Alberonn
Spacescooter Operator
*****
Offline Offline

Posts: 41



WWW
« Reply #9 on: December 06, 2007, 02:56:32 PM »

You say you can't use wget or lynx, but have you tried curl? I've used Drupal and I found that for my cron
Code:
curl -s http://yoursite.com/integration/cron.php
worked the best.
How do you get the cURL call to output to the 'bit bucket?'
I can't test it right now, but I assume this should work:
curl -s -o /dev/null http://yoursite.com/integration/cron.php
Logged
lexhair
Galactic Royalty
*****
Offline Offline

Posts: 402


« Reply #10 on: December 07, 2007, 11:35:58 AM »

I can't test it right now, but I assume this should work:
curl -s -o /dev/null http://yoursite.com/integration/cron.php
Looks like that works just fine. Nice not having to specify the full path to curl.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: