How to make Drupal $ base_url work for cron?

How to get $ base_url to show the correct url of my Drupal site when I start cron? Do I have to set global $ base_url manually for this to happen? Should I run a cron job as a registered user?

When I start mysite.com/cron.php manually, everything works fine: $ base_url is set to the correct URL. However, when I run a similar command via cron or drush, $ base_url is set to the common "http: // default".

The funny thing is that when I start cron manually as a registered user from within Drupal (for example, using devel), $ base_url aways points to the correct URL.

Any suggestions?

Thanks in advance,

Leo

+5
source share
2 answers

Your cron may be configured incorrectly.

You can use wget or curl, which is basically the same as running cron manually. Something like that:

5 * * * * wget http://example.com/cron.php

Perhaps you are using drupal.sh, which claims that you should use "http: //default/cron.php as a URI". This will disrupt the processing of $ base_url. The following may work with drupal.sh.

5 * * * * /path/to/drupal.sh --root /home/site/public_html/ http://example.com/cron.php

When using drush, you may need the -uri argument:

drush --uri=http://example.com cron

You can also just set the $ base_url variable in settings.php (this is the absolutely correct way to do this, not hack).

+6
source

Let you need to go through several possible reasons:

  • wget, curl lynx . , , . : , sysadmin .
  • wget, curl . cron , , -silent -quit, . , . . : sysadmin, .
  • cron.php. , , : cron.php " ". , cron.php (Drupal "Admin" Logs "Recent Events). , cron . . , cron.php " -", .htaccess apache, . IP .
0

All Articles