Cron not working in multi-site Drupal

PerryM - July 27, 2008 - 14:01

I have my hosting provider execute Cron every 15 minutes – sadly this ONLY results in the default web site's Cron being run and other multi-sites Cron never get executed. You can easily check this for yourself.

This prevents Notifications from sending eMails and other modules that rely on Cron for various tasks are never being executed on any but the default installation.

Is there a work around?

=-=

VeryMisunderstood - July 27, 2008 - 14:11

How many cron jobs are set up ?

just the one ? or is one set up for each address of the multisite ?

One Cron job is all I can

PerryM - July 27, 2008 - 14:36

One Cron job is all I can do. There is just ONE Drupal installation with 100+ web sites under my "sites" folder.

Each site uses the same mySQL but each as a unique prefix in that one database.

Drupal's Cron job would need to know what those 100+ prefixes are in order to run each.

I can't set up 100 Cron jobs at the hosting site since there is but ONE cron.php.

This sounds like an oversight in the multi-site Drupal scheme to me.

I'm guessing that Cron needs one input - the mySQL prefix and this will solve this problem. I could then set up 100 Cron jobs; but this is a pain in the butt.

Just as an aside the major problem with Multi-Site is the fact that Drupal views "www.mysite.com" and "mysite.com" as two unique web sites - they are not. I messed with .htaccess to make everything "www.mysite.com" but this screws up Cron when it runs so I now have 200+ file folders 100+ for "www.mywebsite.com" and 100 for "mywebsite.com" - this is a hassle and Drupal should be fixed to just look for "mywebsite.com" and use that for both cases.

=-=

VeryMisunderstood - July 27, 2008 - 14:37

I don't believe the above is correct.

cron jobs get set up with an absolute URL to the cron.php file. In a multisite setup, drupal checks the sites folder for matching address and when it finds one uses the index.php of the core. The same would happen with cron.php as far as I can tell through my own experiments and setups.

ie:
site 1's cron.php is called when http://www.yourmainsite.com/cron.php is run
site 2's cron.php is called when http://www.your2ndsite.com/cron.php is run

in my use case I have a main domain and a subdomain on multisite

I call http://www.maindomain.com/cron.php in my cron job
and I call http://subdomain.maindomain.com/cron.php in my cron job

and both sites get cron to run. While you are correct that there is only one cron.php file, the same holds true for index.php and any file in core for that matter. Drupal is smart enough to understand what to run basesd on the settings.php of the sites/somedomain folder. Where you've included the prefix of the db for that specific site.

I use Powweb for hosting and

PerryM - July 27, 2008 - 14:42

I use Powweb for hosting and they force you to execute Crons like this:

http://useraccount.powweb.com then you get to specify the Cron job in your file directory.

I can't do it anyother way but I'll give them a call and see if there is a way around this.

Thanks for the input.

sounds unusually

WorldFallz - July 27, 2008 - 15:10

sounds unusually restrictive-- might be time for a new web host. I don't know much about powweb, but site5 is cheaper, seems comparable, and allows full custom crons, shell, ffmpeg, etc. (Disclaimer: i have no relationship to site5 other than being a happy shared hosting customer, my sandbox sites are there).

===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime."
-- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz

I'll look into them...

PerryM - July 27, 2008 - 15:19

So at that place the scheduler will execute:
http://www.mywebsite01.com/cron.php
http://www.mywebsite01.com/cron.php
... to 100

And it would be like typing them into my browser's address box?

Thanks.

=-=

VeryMisunderstood - July 27, 2008 - 15:26

I don't normally suggest this, but if you are unwilling to move, I'd investigate the poormans cron.module in the downloads area. which triggers cron through users. It has some overhead but if you have no other way, it's an option.

add it to sites/all/modules and enable it on every site. I'd consider enabling it on a hand full of sites at a time to gauge resource usuage.

=-=

VeryMisunderstood - July 27, 2008 - 15:23

I'm a happy site5 customer too. Just recently moved my account over to the servers at the planet which have Apache 2 and PHP 5.2.x

Sped up my site quite a bit.

Ok, I'm getting 2 accounts

PerryM - July 27, 2008 - 15:39

Ok, I'm getting 2 accounts this second - one production and one play.

Thanks much guys...

P.S.

Setting up an account there and the first thing they offer is the option for unique IP address that costs and extra $3 per month.

Do I need this to make the 100+ Cron jobs run?

Thanks

=-=

VeryMisunderstood - July 27, 2008 - 16:00

I don't have a unique IP for every site in a multisite.

I'm off and running

PerryM - July 27, 2008 - 16:26

Thanks much, I've got 12 hours to qualify under their current promotion - now if I can just find a promotion code.

I really thank you guys.

P.S.

Found one - TWENTYDOLLARS gives you $20 off the order.

Site5 hosts my sites now

PerryM - July 28, 2008 - 05:00

Well I'm up and running on Site5 - still trying to get Cron to run :(

I like what I see but they don't offer php 5+ yet so some modules, like TipJoy, don't work.

I wonder how many php 5+ modules there are for Drupal?

=-=

VeryMisunderstood - July 28, 2008 - 12:19

Yes they do have PHP5. PHP 5.2.5 to be exact.

In your public_html folder should be a .htaccess file
Open it
add to the top of it

AddHandler application/x-httpd-php5 .php

found here: http://forums.site5.com/showthread.php?t=7816 at the site5 forums.

mucho gracious!

PerryM - July 28, 2008 - 13:24

Thank You.....thank you......thank you....
Thank You.....thank you......thank you....
Thank You.....thank you......thank you....
Thank You.....thank you......thank you....

Ok, now if I could just win the Powerball lottery... :)

=-=

VeryMisunderstood - July 28, 2008 - 14:02

I can help with many things ... powerball is not one of them. sorry! : )

I'm baaaaaaack

PerryM - July 28, 2008 - 16:27

Sorry to pester you but Site5 now says I can't run Cron jobs for my multi-site Drupal! Arrrrrgh.

Here is the Cron Job I can successfully run for my default Drupal:

php -q /home/myid/public_html/drupal/cron.php

They say I can't run things from the keyboard like:

www.anotherDrupalSite.com/cron.php

I sure hope they are wrong.....

Thanks for any advice.

I think you're mixing

WorldFallz - July 28, 2008 - 16:48

I think you're mixing methods here. If you invoke cron.php with php, you need to use the linux path-- as in your first command above. So for a subsite it would be:

php -q /home/myid/public_html/drupal/sites/myothersite.com/cron.php

If you want to use URLs, you'll need to invoke cron with wget or lynx.

===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime."
-- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz

Site5 gave up...

PerryM - July 28, 2008 - 17:57

Site5 told me that I can't do what I want to do - same problem as with Powweb - something about the IP address.

I guess it's back to Powweb, which is much cheaper, and I will have to have multiple copies of Drupal in order for Cron to work.

This has been a real disappointment - I picked Drupal since I just wanted ONE copy of the CMS and that's all I needed to worry about.

Thanks for all the help...

=-=

VeryMisunderstood - July 28, 2008 - 18:02

have you exhausted all resouces ?

http://drupal.org/node/237503

always keep in mind that you have no idea the level of tech support you are getting and lastly, no hosting company supports 3rd party software.

Ignore my brain spasm from

WorldFallz - July 28, 2008 - 19:00

Ignore my brain spasm from earlier, I forgot we were talking multisite, LOLOL.

Anyway, I've got multisite cron working on site5 no problem just put:

curl http://subdomain.domain.com/cron.php

In for your cron command for each site.

Keep in mind hosting companies generally don't support 3rd party installs like drupal. Although I have to say, I've been more pleased with the response and help I've requested from site5 than any other hosting company i've tried recently. That said however, their answers are not always correct which is why i usually find most of my answers/assistance in the site5 forums.

===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime."
-- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz

also-- don't blame the

WorldFallz - July 28, 2008 - 19:03

also-- don't blame the shortcomings of shared hosting on drupal ;-)

===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime."
-- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz

Me happy :)

PerryM - July 28, 2008 - 20:57

Finally did it - thanks guys.

Here is what I had to do:

The default Drupal Cron job: php -q /home/myID/public_html/drupal/cron.php

For all the rest multi-sites:

curl http://www.mywebsite.com/cron.php

I have www.mywebsite.com mapped to /home/myID/public_html/drupal

This works and now it's time for a Margarita...

P.S.

Site5 runs Drupal at least 5 times faster than Powweb :) Maybe even 10 times faster for the first startup of a page in a while. (Caching turned off in both cases)

P.P.S.

You are not going to believe this - I took the Cron command:

Curl www.mywebsite.com/cron.php

And this works on Powweb!!!!!!!!!!!

Arggggggggg - if I had know this I'd never have blown 2 days on this.

I'm sticking with Site5 since it's so much faster and leaving Powweb to use as my play site...

Arrrrrrrrrrrrrggggggggg!!!!!!!

I pay $50 to PowWeb a year

PerryM - July 27, 2008 - 15:16

I pay $50 to PowWeb a year to have unlimited disk space and throughput on their shared hosting site (and 75 mySQL's).

Sadly there is but one IP address that all my Drupal sites map to so there is no way for Powweb to execute 100 Cron jobs like http://www.mywebsite01.com/cron.php and then http://www.mywebsite01.com/cron.php. They all wind up executing the default Drupal site.

I would have to upgrade to a virtual hosting site that costs big bucks $480 per year.

So what I need is a way to code some php to run the 100 Cron jobs when the default site's Cron is run every 15 minutes.

Arrrrrgh........

 
 

Drupal is a registered trademark of Dries Buytaert.