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:
It returns an odd response:
Status: 302 Moved Temporarily
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.
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:
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…