Opened 10 years ago
Last modified 7 weeks ago
#39340 new defect (bug)
Scheduled Posts are being missed (problem with wp-cron.php?)
| Reported by: | remarkablemike | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Cron API | Version: | 4.6.1 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
Scheduled posts are missing their set time. This is not an issue with out server times, nor is it an issue with the cron jobs.
I have seen that many other users are experiencing problems with this, but as of yet there has been no word from WordPress.
Has this been fixed in 4.7? Or is this still outstanding?
Attachments (2)
Change History (16)
#1
in reply to: ↑ description
@
10 years ago
#3
follow-up:
↓ 4
@
10 years ago
- Summary Scheduled Posts are being missed → Scheduled Posts are being missed (problem with wp-cron.php?)
It's possible that I might have a related problem. I recently moved web hosting providers, and am having a problem that the cron for the wp-lifestream plugin isn't working. However, I have now installed the WPX Cron Manager Light plugin, and there are many other plugins that aren't working. I have attached some screen captures from WPX Cron Manager.
On page 1, wp_version_check is listed as 13 days late.
I have pushed the "Execute Now" for lifestream_cron, which updates the timer, but the actual cron has not created any updates.
I am running Wordpress 4.7.2.
In wp-config.php, I have tried setting ALTERNATE_WP_CRON as directed at https://codex.wordpress.org/Editing_wp-config.php#Alternative_Cron , but this doesn't not seem to help.
If someone would like to suggest additional diagnostic steps, they would be welcomed.
#4
in reply to: ↑ 3
@
10 years ago
I had the same problem, and figured out that due to server resource overload, hoster disabled cron automaticaly because it sensed a security issue. You should fix your webpage serving issue, and optimize it more efficiently, or transfer to more resourceful hosting package.
Replying to daviding:
It's possible that I might have a related problem. I recently moved web hosting providers, and am having a problem that the cron for the wp-lifestream plugin isn't working. However, I have now installed the WPX Cron Manager Light plugin, and there are many other plugins that aren't working. I have attached some screen captures from WPX Cron Manager.
On page 1, wp_version_check is listed as 13 days late.
I have pushed the "Execute Now" for lifestream_cron, which updates the timer, but the actual cron has not created any updates.
I am running Wordpress 4.7.2.
In wp-config.php, I have tried setting ALTERNATE_WP_CRON as directed at https://codex.wordpress.org/Editing_wp-config.php#Alternative_Cron , but this doesn't not seem to help.
If someone would like to suggest additional diagnostic steps, they would be welcomed.
#5
@
10 years ago
@vonkoga Thanks for the followup.
I worked with my web provider (PlanetHoster), disabled the Wordpress virtual cron, and created the cron in cPanel. The instructions varied a little bit from https://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/configuring-a-cron-job-for-wordpress , but that's the general idea.
My problem wasn't a server resource overload. My shared web hosting comes with 4GB of RAM (!) and it typically runs at less than half of that, across multiple web domains. I still haven't got a definitive diagnosis of the problem, but have dissolved it by configuring in cPanel.
#6
@
7 years ago
WP's problem with posting scheduled posts reliably, even if they're slightly late - better a bit late than never or really late - has been plaguing it for years. It's time to resolve it.
Numerous solutions have been created, but they're all bloated or use up too many resources (such as checking on every page load):
https://github.com/sLaNGjI/wp-missed-schedule
https://wordpress.org/plugins/scheduled-post-trigger/
https://wordpress.org/support/topic/switch-logic-to-wp-cron/
etc.
Can WP just sort this out so it's not a problem almost every day?
Thanks.
#7
@
7 years ago
I have the same problem, on the latest 5.3.2 with wordpress under cloudflare with this in the wp-config.php, cron executed by the system cron using php wp-cron.php every 5 minutes on sunday the posts scheduled on that day are not published.
<?php define('DISABLE_WP_CRON', true);
Debugging the file the script is executed rightly and I don't see any errors but in the dashboard they are marked as missed scheduled. I see that during the week the posts scheduled are published with no errors but just on sunday where the backend is not used there are those issues.
As configured in this way I think that they should be published aldo without accessing the backend because now the cron is server side.
I was thinking to do a script that login on sunday every 5 minutes with a specific user on the backend just to get the posts pubished.
#8
@
7 years ago
I've been digging into this issue for a while and discovered the real culprit - race conditions with the cron array in the db.
See #49520 for the details.
In the meantime, we've implemented a watchdog that fires every minute and checks for posts that had missed schedule.
We're also looking into Cavalcade as the proper solution.
#9
@
7 years ago
I am wondering if we can patch wordpress as it is now because before that someone reimplement the other ticket you mentioned (that I already saw) can takes years.
As I don't have any errors or some sample data to test is difficult for me to replicate outside production and write a patch.
#10
@
7 years ago
I am investigating this problem, as wp-cron.php doesn't fire any log information I added a error_log(print_r($crons, true)); at line 149 before the delete of the transient to track at every call what crons are found.
As I can see the crons are found but not executed:
[1585036816] => Array
(
[publish_future_post] => Array
(
[799cb85576dde4649c55321c2ce6e65b] => Array
(
[schedule] =>
[args] => Array
(
[0] => 246700
)
)
)
)
So I am wondering if https://github.com/WordPress/WordPress/blob/7004afe4f4bac1fd17a142051832bdf6be8e6fcf/wp-includes/post.php#L4293 it is working.
As I can see this function check_and_publish_future_post doesn't have any test and the last changes to that function are from a lot of years ago.
#11
@
7 years ago
In my testing, seems that check_and_publish_future_post is not invoked on some posts also if should do it.
The event is removed on deleting the post https://github.com/WordPress/WordPress/blob/7004afe4f4bac1fd17a142051832bdf6be8e6fcf/wp-includes/post.php#L3059 but I cannot see any mention of that execution.
Maybe that hook should be fired more often? It can explain why they appear as post but no cron is executed for them.
This ticket was mentioned in Slack in #core by johnbillion. View the logs.
7 weeks ago
This ticket was mentioned in Slack in #core by regio_online. View the logs.
7 weeks ago
#14
@
7 weeks ago
Following a discussion in the #core Slack channel, @johnbillion suggested that I document these findings here rather than open a new ticket.
I have been investigating this issue in a live production environment: a Dutch national news site publishing approximately 19 new posts per day. Occasionally, a scheduled post remains in future status after its scheduled publication time has passed.
As a practical test, I implemented a lightweight watchdog/recovery layer that periodically checks for overdue future posts and recovers eligible posts. This is deliberately a defensive mechanism: it does not replace WP-Cron, modify cron storage, or attempt to determine or solve the underlying cause of the missed scheduled event.
So far in production, it has detected and successfully recovered 6 genuine missed scheduled publications, with 0 failed recoveries. The original scheduled publication date and time are preserved.
I noticed the earlier comment in this ticket about implementing a watchdog that periodically checks for posts that have missed their schedule. The mechanism I have been testing follows essentially that same defensive approach, but adds safety limits, logging, diagnostics, and preservation of the original scheduled publication time.
I have published the current implementation as an open-source proof of concept here:
https://github.com/RegioOnline/wp-schedule-monitor
Current beta: 0.4.1-beta.3
The implementation is intentionally narrow in scope. Its purpose is simply to provide a second recovery path when a post is still future after its scheduled time has passed, regardless of why the original publish_future_post event did not result in publication.
I am happy to provide further production observations, diagnostics, or implementation details here if that would be useful in exploring a Core-level safeguard.


Replying to remarkablemike:
I have this problem with 4.7–en_GB.
I've tried using Alternative_Cron, disabling plugins, disabling Cloudflare, and manually visiting pages during scheduled times - but it still doesn't work.
Other cron jobs work on my server.
Given the large numbers of people having this problem, and the popularity of plugins which claim to solve this issue, I suspect it is a fundamental flaw with how WordPress works.
As per https://developer.wordpress.org/plugins/cron/
This is now demonstrably false.
My suspicion is that
wp-cronis failing in an unspecified way. There was a proposal to display detailed error messages - but it was abandoned #23133Using get_cron_array(), I can see that future posts are being placed in the schedule:
[1484813336] => Array ( [publish_future_post] => Array ( [0da9aa88af9739142d6b46c1ce06de2d] => Array ( [schedule] => [args] => Array ( [0] => 24563 ) ) ) )I wonder if there's a problem with the schedule there? Other jobs look like this
[1484187126] => Array ( [jetpack_v2_heartbeat] => Array ( [40cd750bba9870f18aada2478b24840a] => Array ( [schedule] => daily [args] => Array ( ) [interval] => 86400 ) ) )I don't *think* that there should be a schedule for one off events like posting a blog, but I can't be sure.