I'm trying to get cron jobs set up for a client. Here's the cron command I'm trying to use:
/usr/bin/php /home/ACCOUNTNAME/public_html/cron.php
(This is copied from another production Drupal site's cron setup, on the same hosting provider -- albeit D5, not D6. Naturally ACCOUNTNAME was changed to match the current client, and naturally I've verified that the page is actually getting loaded.)
They're on Hostgator. I've got the job configured to run every 15 minutes, and I can confirm that it is running and that the cron.php page is being loaded, but it's not being executed: Instead, what I get in the cron email is a message that begins like this:
Status: 503 Service Unavailable
X-Powered-By: PHP/5.2.8
Content-type: text/htmlThat's followed by the HTML for a Garland-themed page which presents the following message -- I've cleaned up some of the HTML for the sake of clarity:
Site off-line
The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.
If you are the maintainer of this site, please check your database settings in the
settings.phpfile and ensure that your hosting provider's database server is running. For more help, see the handbook, or contact your hosting provider.The mysqli error was: Access denied for user 'DATABASE USERNAME'@'localhost' (using password: YES).
Key information:
- The value that's displayed for DATABASE USERNAME is consistent with Drupal trying to load the correct settings.php file.
- The site appears to be functioning normally, other than this.
- Site theme is NOT Garland; site is NOT configured to use an administration theme.
- cron.php executes normally if it is run from a web browser by an anonymous user.
- Site is not in maintenance mode.
- The failed cron job produces no log entry. (I suppose that makes sense since the error message says there's no database connection.)
I've googled around on this and haven't found anybody reporting the same problem.
Any ideas?
Comments
SOLUTION, but not full explanation
What I think I've discovered is that if you aren't using lynx, wget or curl to load cron.php, the default settings.php file has to have the database connection info for the site that you want to run cron against.
Put another way: when run by the PHP interpreter, cron.php does not seem to walk the tree of the /sites folder to find the correct config file. Which makes sense when you realize that it has no http host to check against.
This seems to imply that if you are using a multisites configuration, you MUST use curl, lynx or wget (i.e., something that actually does an http transaction) to run cron.php, or cron.php won't be able to tell what settings.php file to load. The reason would be that in a multisites scenario, cron.php needs to be able to tell what site it's running on, and to do that it has to have a URL.
(Of course, this makes perfect sense when I've been banged over the head with it.)
The key piece of information is that the database user ID in the error message was not correct, contrary to my original report. (They all look the same after a while.)
Had the same problem
I experienced the same problem with setting up a multi-site environment on HostGator, but don't know specifically what caused my database and/or username to become altered. My settings.php still had the original username and password so I assumed that it must be the password in the database that had become screwed up.
As such the easiest way I found to solve the problem was to simply create a new username and password for the databse. Specifically I did the following:
1. I went to phpMyAdmin.
2. Created a new user with a new password.
3. Added User to the right Database (remembering to give it full privileges).
4. Then replaced the username and password in the settings.php file (line92)
This worked fine for me, I hope it helps someone else.