Cron.php didn't work from crontab
OZ - November 7, 2005 - 15:51
Hello. Sorry for my bad english.
I'm trying to set cron.php calls from crontab.
When i run cron.php from browser (chmod 755) - it works, when its calling by crontab - errors happen.
Here is these errors:
PHP Warning: main(sites/default/settings.php): failed to open stream: No such file or directory in /home/_myaccount_/www/includes/bootstrap.inc on line 642
PHP Warning: main(): Failed opening 'sites/default/settings.php' for inclusion (include_path='.:') in /home/_myaccount_/www/includes/bootstrap.inc on line 642
PHP Warning: main(includes/database.inc): failed to open stream: No such file or directory in /home/_myaccount_/www/includes/bootstrap.inc on line 643
PHP Warning: main(): Failed opening 'includes/database.inc' for inclusion (include_path='.:') in /home/_myaccount_/www/includes/bootstrap.inc on line 643
PHP Warning: main(includes/session.inc): failed to open stream: No such file or directory in /home/_myaccount_/www/includes/bootstrap.inc on line 644
PHP Warning: main(): Failed opening 'includes/session.inc' for inclusion (include_path='.:') in /home/_myaccount_/www/includes/bootstrap.inc on line 644
PHP Warning: main(includes/module.inc): failed to open stream: No such file or directory in /home/_myaccount_/www/includes/bootstrap.inc on line 645
PHP Warning: main(): Failed opening 'includes/module.inc' for inclusion (include_path='.:') in /home/_myaccount_/www/includes/bootstrap.inc on line 645
PHP Fatal error: Call to undefined function: db_fetch_object() in /home/_myaccount_/www/includes/bootstrap.inc on line 199Note: this errors have appears only when calling cron.php from crontab (in other scripts bootstrap.inc works fine).
In bootstrap.inc (642-645):
include_once "$config/settings.php";
include_once 'includes/database.inc';
include_once 'includes/session.inc';
include_once 'includes/module.inc';All inc-files are found where it is necessary (in includes/).
Can you help me?

Solution
I'm hope, that my posts will be useful for somebody.
I've just add in bootstrap.php
if (getcwd()=='/home/my_account') chdir('my_syte/www/');For example, it's can to look as:
if (getcwd()=='/home/host12345') chdir('example.com/www/');With best regards, OZ. Drupal is genius system! :)
Hello,I am getting the same
Hello,
I am getting the same errors. While your solution seems to be on the right track, the explanation is too arcane for me. Are you referring to the bootstrap.inc file? And, where in the file do I put the chdir command?
Re: same
I've put chdir at line 641 in bootstrap.php (before
include_once "$config/settings.php";).My crontab works orderly, but when script script is caused from it, the current dir becomes the directory of crontab, but not of script directory.
I simply check this (getcwd) and correct (chdir).
sorry for my english.
THANK YOU!
I have spent days of frustration trying to work this out. Your solution is simple and elegant. I think this is a bug in the programming that should be addressed.
My cron jobs are now running smoothly.
Can you tell us what your
Can you tell us what your crontab line is? - I think that must be wrong.
while you
While you are helping people with the crontab:
50 10 * * * /usr/local/bin/php $HOME/htdocs/site1/cron.php >>$HOME/htdocs/savelogs/cron_oti.log 2>>$HOME/htdocs/savelogs/cron_oti.err
(It's all one line). It does not get executed and I see no log files either. /usr/local/bin/php is the correct path for my hosting provider.
Andre
-------------------------------------------------
http://www.opentravelinfo.com
http://www.aguntherphotography.com
Hello and thanks for
Hello and thanks for responding. My crontab line is:
/usr/local/bin/php /hsphere/local/home/concresc/drumcirclereview.com/cron.php
Here is the email I am getting from the cron job:
Warning: main(sites/default/settings.php): failed to open stream: No such file or directory in /hsphere/local/home/concresc/drumcirclereview.com/includes/bootstrap.inc on line 642
Warning: main(): Failed opening 'sites/default/settings.php' for inclusion (include_path='.:/usr/local/lib/php') in /hsphere/local/home/concresc/drumcirclereview.com/includes/bootstrap.inc on line 642
Warning: main(includes/database.inc): failed to open stream: No such file or directory in /hsphere/local/home/concresc/drumcirclereview.com/includes/bootstrap.inc on line 643
Warning: main(): Failed opening 'includes/database.inc' for inclusion (include_path='.:/usr/local/lib/php') in /hsphere/local/home/concresc/drumcirclereview.com/includes/bootstrap.inc on line 643
Warning: main(includes/session.inc): failed to open stream: No such file or directory in /hsphere/local/home/concresc/drumcirclereview.com/includes/bootstrap.inc on line 644
Warning: main(): Failed opening 'includes/session.inc' for inclusion (include_path='.:/usr/local/lib/php') in /hsphere/local/home/concresc/drumcirclereview.com/includes/bootstrap.inc on line 644
Warning: main(includes/module.inc): failed to open stream: No such file or directory in /hsphere/local/home/concresc/drumcirclereview.com/includes/bootstrap.inc on line 645
Warning: main(): Failed opening 'includes/module.inc' for inclusion (include_path='.:/usr/local/lib/php') in /hsphere/local/home/concresc/drumcirclereview.com/includes/bootstrap.inc on line 645
Fatal error: Call to undefined function: db_fetch_object() in /hsphere/local/home/concresc/drumcirclereview.com/includes/bootstrap.inc on line 199
Tell me if I am wrong but it appears that crontab is finding the cron.php since it is making its way to the bootstrap.inc file. From there, however, it seems to not be able to find the other include files. I am assuming that it is a path problem.
What do you think?
Thanks for the help.
JJ
In addition
I thought this could be solved by using one of the .sh scripts provided but my provider does not seem to have a lynx editor. I have tried both the cron-lynx.sh and the cron-curl.sh scripts and numerous combinations of path statements to no avail. The above crontab line is what was recommended by my ISP.
Thanks again,
JJ
Yes, way is incorrect
Yes, you are absolutely right. I have answered above.
Isn't reason
All cron-tasks executes orderly.
And in Drupal-modules too (after correcting).
I have the same error
I have the same error messages, my command is:
00 17 * * * php /home/httpd/vhosts/mysite.com/httpdocs/cron.phpElegant solution
OZ, привет! ;)
There is more elegant way to do that, without changing Drupal’s code.
Use this command line:
cd /home/httpd/vhosts/yoursite.com/httpdocs/; php cron.phpexplanation: first set up current directory, then run the script.
Ainur
Nice one, that really did the trick. For me I had to execute (second part of the command, after the ; ) the php-parser like this:
/usr/local/bin/php -q -f cron.php
this is in DirectAdmin, but it wil probably work on other systems as well
didn't work for my :(
didn't work for me :(
Try cron-curl.sh
Why don't you try curl?
It worked for my drupal set up.
Here's the link to the topic "Multisite with cron-curl.sh"
http://drupal.org/node/237506
It works for both single and multi-site.