Share » Forums » General » Help - Cron Job DB Error

Help - Cron Job DB Error

Help - Cron Job DB Error

Thursday 17 April 2008 7:03:26 am - 13 replies

Author Message

Xavier Gouley

Thursday 17 April 2008 1:22:32 pm

Hi,

It seems that your PHP executable used by Apache has MySQL module (or else) activated, and then the site can access the database, but the PHP executable used in your shell (with cronjobs, or in command line mode), called PHP CLI does not support your database because the MySQL (or else :)) module is not activated.

If you have compiled yourself your PHP executable, perhaps you have to do a
"make install cli" (I'm not sure of the right syntax).

Please also confirm that when you type "php --help" or "php --version", the PHP responding is the right one (PHP CLI mode).

Good luck !

Xavier Gouley
http://www.gxapplications.com/eng_blog/GX-Admin-s-Blog/

Greg Sanderson

Friday 18 April 2008 1:15:47 am

Hi

Thanks for your quick reply.

I have checked the php version by typing "php --version" and it returns

PHP 5.1.6 (cli)
then all of the copyright stuff, and about Zend.

So it seems CLI is there.. how can I check if the MySQL module is there too? Would this be there by default?

Thanks.

Sascha Frinken

Friday 18 April 2008 1:32:39 am

In your shell type:

     php -m

HTH

Sascha

Greg Sanderson

Friday 18 April 2008 1:45:16 am

Ok, done that and in the list of modules is both mysql and mysqli..

I tried changing ezmysql to ezmysqli in site.ini and that made no difference either.

However I typed runcronjobs.php -d at the command line and this generated an entirely different error message:

PHP Fatal error: ezINI: Undefine group 'FileSettings' in site.ini in (folder)/lib/ezutils/classes/ezdebug.php on line 553.

That line number is simply an error message output line and so is no help.

I checked site.ini and there IS a block for FileSettings for all siteaccesses which is really odd. But it seems there must be some problem with this file.

Kristof Coomans

Friday 18 April 2008 2:21:00 am

Hi Greg

Looks like you have safe mode / open_base_dir enabled. Make sure you disable them.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Greg Sanderson

Friday 18 April 2008 3:17:17 am

Hi

Ok now when I run runcronjobs.php in the command line it works. However when I run it as as a cron job I still get the no database handler error message.

I checked in the eZ setup "system information" and it says that both safe mode and the open basedir are off. Unless it thinks they are off and they are really on?

André R.

Friday 18 April 2008 4:04:42 am

> I checked in the eZ setup "system information" and it says that both safe mode and the open basedir are off. Unless it thinks they are off and they are really on?

php-cli uses a different set off settings then the php version used on web (including system information page), the version used on web is mostly cgi, fastcgi or apache module version of php. So basically even if system information page says it is turned off, this doesn't mean it's turned off in the cli version of php..

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Greg Sanderson

Friday 18 April 2008 8:47:55 am

Yes it must be that safe mode is on for the cron job but not for the ssh command line which seems really silly since they are both the same version when I run php -v from both. Does anyone know how to change the settings for the cron job one to turn safe mode off?

Thanks

Kristof Coomans

Friday 18 April 2008 9:33:21 am

Hi Greg

To make sure this is the problem, can you let the cron job do a php -i and check the output for open_basedir, safe mode and which PHP ini file is used.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Greg Sanderson

Saturday 19 April 2008 10:09:13 am

Hi

I have done that using the cron job to call /usr/bin/php -i and I get all of the info including:

Configuration File (php.ini) Path => /etc/php.ini
Scan this dir for additional .ini files => /etc/php.d
additional .ini files parsed => /etc/php.d/dom.ini,
/etc/php.d/gd.ini,
/etc/php.d/imap.ini,
/etc/php.d/mbstring.ini,
/etc/php.d/mysql.ini,
/etc/php.d/mysqli.ini,
/etc/php.d/pdo.ini,
/etc/php.d/pdo_mysql.ini,
/etc/php.d/pdo_sqlite.ini,
/etc/php.d/xmlreader.ini,
/etc/php.d/xmlwriter.ini,
/etc/php.d/xsl.ini

open_basedir => no value => no value

safe_mode => Off => Off
safe_mode_exec_dir => no value => no value
safe_mode_gid => Off => Off
safe_mode_include_dir => no value => no value

This must be getting its settings from the /etc/php.ini since when I set safe mode to off in there the cron job picks it up as being off.

Also I did discover one strange thing that may help fix this: when I login using SSH and type /usr/bin/php (pathtoeZ)/runcronjobs.php I get the same "No database handler" error message on the command line. BUT if I then type cd (pathtoeZ) and THEN from there type exactly the same command in it works! So it must be that the cron job is running it from the same place where it can't find the database handler, but (even though I put the full path both times) when run from inside the eZ folder the same command works. Really strange...

Do you know why this should be? Thanks!

André R.

Saturday 19 April 2008 10:24:35 am

http://ez.no/doc/ez_publish/technical_manual/4_0/features/cronjobs/running_cronjobs :

Running cronjobs from the shell
1. Navigate into the eZ Publish directory.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Greg Sanderson

Monday 21 April 2008 1:07:30 am

FIXED!

Thank you all.

The problem was to do with changing to the eZ directory using the cron job. I had tried installing that .cron file but got some errors about "bad minutes". I could not see any white space in front of the minutes but anyway gave up doing that and used my Plesk control panel to add the same code using the "scheduled tasks" tool. I did not know you could use && to add two commands in the same job - this was the key since I could then change to the right directory and then run the command from there in the cron job.

So it works!

Thanks.

Mark Emms

Saturday 11 April 2009 1:42:47 am

That's interesting Greg - did you have to give a full directory path from /var/www/vhosts to do that?

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu