Real cron job causing premature end of script headers


#1

Hi!

Lately, and with the help of Dreamhost support, I switched from Wordpress cron job to rel cron job. My settings have the cron jobs run every two hours. I have confirmed that it is working: scheduled tasks on my Wordpress installation are performed.

The reason I have done that is the following: lately, the site was slow and, again with the help of Dreamhost support, I learned that my installation was maxing the RAM limit and that ProcWatch was therefore killing scripts (of course I should add that my Wordpress is on a shared server).

Things look much better now, but examining my error.log I see that almost every time the cron job is launch, I get a “Premature end of script headers”. The entry in the log looks like this:

[Sun Jan 27 12:00:13 2013] [error] [client ip.add.ress.of.server]
Premature end of script headers: wp-cron.php

It seems to me that the cron job –or something associated with the cron job– is eating to much memory. Is the cron job inadequately configured (I doubt it, it’s quite simple to set via the cPanel) or is one of the task scheduled to be perform by the cron job asking for too much resources?

Basically, I’d like to find out why the cron job is causing those premature end of script header.

Any theory? Or idea how to troubleshoot this?

It would be greatly appreciated. I stopped sending emails to the support because I thought I could continue my troubleshooting here instead of adding another load on them.

Thanks!

P.


#2

Hi,

Ok yes, I know it’s an overload issue. But what’s the relation with the cron job? Why specifically the cron job and not something else?

More importantly: Can I infer from that that a plugin requiring the cron job is causing the overload when the cron job executes? If so, I could try deactivating the plugins one by one until the error stop being logged, thus identifying the plugin that is causing the overload when the cron job kicks in. Or am I wrong?

Also, my error logs are often smaller than 1KB. A big log would be 2KB. Does this mean I can safely ignore the issue (or, to put it in other words, that there is no issue)?

Thanks for your feedback, I appreciate it.

P.


#3

Have you tried using curl instead of wget?

I use ‘curl http://example.com/wp-cron.php’ and it runs really well.

Also what plugins are you using that have their own wp-cron jobs? I see you have an optimize plugin for your DB, and that could be causing this. That’s not a lightweight plugin.


#4

Hi!

Thanks for answering me!

  1. I was told by DreamHost support that since my wp-config file is located outside the main directory of my WordPress installation I must use wget.

  2. The database plugin is not automated: it’s manual only. I use the plugin “What’s In Cron” to see what cron jobs are running. The cache plugin W3 Total Cache seems to be the most hungry. Besides that, the other plugins requiring cron are a security plugin (they told me that 2 hours was a good enough frequency for the scan), Yoast SEO plugin, WordPress own cron (for updates, daily), Askimet, and that’s about it. My backup plugin has been disabled for the past 10 days.

  3. Actually, just a few hours ago, I finally got an answer from support suggesting that the error could mean “that the script ran and ended before it could return the response headers the web servers expected” which, as I was told, is not that unusual. I asked for some precision and am waiting for a reply from Support.

Thanks again for the help. If you have more to say, do not hesitate!

P.


#5

I don’t think #1 will matter, since if it did, you’d never be able to hit the site directly.


#6

Ok! Than I should try it. I hope support didn’t provide me with incorrect information (but it’s okay, I can understand: those are complex issues).

So in my cPanel, i should use the curl command to set a real cron job exactly as you showed me: ‘curl http://example.com/wp-cron.php’ ?

Thanks again for the feedback. This forum is a great place to get answer when Support isn’t answering. Good complement.

P.


#7

I’m part of Support actually :wink:

I can see why they’d think the location of the wp-config.php might matter, but (luckily) WP is smart enough to catch that. I tested it on my site just now and it worked (posted a scheduled post for me). So yes, just ‘curl http://example.com/wp-cron.php’ and it’s off to the races :slight_smile: