You have more than one copy of PHP installed on your computer, and they have 
different capabilities. It sounds like the one you want (which has MySQL 
support) is in /usr/local/bin, and it sounds like your PATH variable includes 
the path /usr/local/bin before the location where your second copy of PHP is 
installed (perhaps /usr/bin?). So everything works on your console.

Cron has its own PATH, however. Perhaps cron's PATH does not include 
/usr/local/bin, or perhaps it does, but it's after the location where the other 
PHP is, so that the other PHP (which apparently doesn't have MySQL support) is 
found, and you get an error about undefined MySQL functions.

Figure out how to change cron's PATH. Or specify the PATH yourself before 
running the cake console, e.g.:

PATH=/usr/local/bin:/usr/bin:/bin /path/to/cake/console/cake

Or if you're doing it as in the book page you linked to, and you already have a 
wrapper script around the cake console, set the PATH within that wrapper script.


On Dec 7, 2010, at 13:23, [email protected] wrote:

> I found out that I can fix the problem by calling php with its
> absolute path in cake/console/cake:
> 
> From:
> exec php -q ${LIB}cake.php -working "${APP}" "$@"
> 
> To:
> exec /usr/local/bin/php -q ${LIB}cake.php -working "${APP}" "$@"
> 
> However, I do not like that solution because it changes Cake core.
> 
> Anyone any clue? Thanks!
> 
> On Dec 6, 11:01 pm, "[email protected]" <[email protected]> wrote:
>> 
>> I followed the instructions 
>> onhttp://book.cakephp.org/view/1110/Running-Shells-as-cronjobs
>> and I still ran into a strange problem while running my shell in
>> cronjob.
>> 
>> I am getting error when I try to use model in the shell:
>> 
>> Fatal error: Call to undefined function mysql_query() in /home/
>> cake1.3.6/cake/libs/model/datasources/dbo/dbo_mysql.php on line 600
>> 
>> The shell runs fine if I just fire it up manually. What can't PHP see
>> mysql_query() when it's done in a shell via cronjob?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to