0

wp-cron and MultiSite = Headache

Posted by danblog on November 15, 2010 in General stuff, How Tos & Tutorials |

After making some changes a while ago to how I run the wp-cron on this blog I noticed some odd problems as scheduled posts weren’t being published.

This was getting to be a rather frustrating so I decided to debug the problem once and for all and eventually came to the conclusion that under a WordPress MultiSite setup the wp-cron runs slightly differently in that it also requires the domain for which it is running, which obviously has problems when calling the file directly via cronjob command.

Lets explain the situation and solution.

I had the cronjob as described previously in my how to disable wordpress cron post, but it seems when calling the wp-cron via cronjob using:

php /home/USER/public_html/wp-cron.php

It returns an odd response:

Status: 302 Moved Temporarily

X-Powered-By: PHP/5.2.14

Location: http://dansgalaxy.co.uk/wp-signup.php?new=

Content-type: text/html

Now after some testing I managed to determine that the wp-cron wasn’t running correctly under cronjob but worked fine when run via url and I began to wonder if each blog within the MultiSite environment requires it’s own wp-cron execution.

So I did a simple test, schedule a post on both blogs, and run the wp-cron from one domain and see it both publish or just one – just one published.

I now knew for definite that each blog needs its own wp-cron to run, which when you are trying to call the wp-cron directly using its server path makes things a little awkward and probably explains the odd error.

Conclusion:

In a multisite setup of WordPress, where you want to run wp-cron from cronjob instead of on every page load you will need to structure the cronjob differently to the previous article. instead you need a cronjob command formatted as such:

curl http://yourdomain.com/wp-cron.php

Note you will need a cronjob for each blog domain hosted.

Simple. Now I shall go to bed and get some sleep and try and ditch the headache this has caused… Smile

Tags: , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2007-2017 Dan's Tech Blog All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.