Looks like WordPress called the 2nd cron job about a minute after the 1st one. Best guess is a slow database lock, so WordPress didn’t know the 1st job was running when the 2nd one was called.
Thread Starter
Ynah
(@ynahpantig)
It’s very random though. Last time it happened was probably around mid-last year. Any suggestions on how to solve or avoid this issue?
You could try using server cron jobs instead. Details in FAQ.
Thread Starter
Ynah
(@ynahpantig)
Ok, I’ll try that out and let you know. Thanks!
Thread Starter
Ynah
(@ynahpantig)
Hi John,
I tried doing that but it looks like it’s not running the wp crons anymore. We had one that would run a clear cache on W3TC and it looks like it didn’t run that. Also, the “next auto post” check is also not being updated anymore. Here’s a screenshot (http://pasteboard.co/CvZ4UvpZY.png). I’ve already manually cleared the cache from W3TC to make sure, but no luck.
The server cron job has to fire to call wp-cron into order to process scheduled jobs.
Thread Starter
Ynah
(@ynahpantig)
Hi John,
Yes, I did add that cron to the server as was instructed in the FAQ but it resulted to the last issue that I mentioned.
It looks like it’s becoming more frequent – it’s been recycling 2 posts for the last 2 days as opposed to 1 post which is in the settings.
Thread Starter
Ynah
(@ynahpantig)
From what I notice in the logs, it’s only checking it twice (and posting twice) when it’s recycling something. Otherwise, when it’s only checking for the time range, it only checks once. Here’s a sample debug log:
2017-02-25 13:04:49 - DEBUG: current time 1304 is not in allowed time range for (sat - 0300), no post check will occur.
2017-02-25 14:04:48 - DEBUG: current time 1404 is not in allowed time range for (sat - 0300), no post check will occur.
2017-02-25 15:04:49 - DEBUG: current time 1504 is not in allowed time range for (sat - 0300), no post check will occur.
2017-02-25 16:04:51 - DEBUG: current time 1604 is not in allowed time range for (sat - 0300), no post check will occur.
2017-02-25 17:04:50 - DEBUG: current time 1704 is not in allowed time range for (sat - 0300), no post check will occur.
2017-02-25 18:04:49 - DEBUG: current time 1804 is not in allowed time range for (sat - 0300), no post check will occur.
2017-02-25 19:04:51 - DEBUG: current time 1904 is not in allowed time range for (sat - 0300), no post check will occur.
2017-02-25 20:04:58 - DEBUG: current time 2004 is not in allowed time range for (sat - 0300), no post check will occur.
2017-02-25 21:04:53 - DEBUG: current time 2104 is not in allowed time range for (sat - 0300), no post check will occur.
2017-02-25 22:05:01 - DEBUG: current time 2205 is not in allowed time range for (sat - 0300), no post check will occur.
2017-02-25 23:05:03 - DEBUG: current time 2305 is not in allowed time range for (sat - 0300), no post check will occur.
2017-02-26 00:04:56 - DEBUG: current time 0004 is not in allowed time range for (sun - 0300), no post check will occur.
2017-02-26 01:04:47 - DEBUG: current time 0104 is not in allowed time range for (sun - 0300), no post check will occur.
2017-02-26 02:04:48 - DEBUG: current time 0204 is not in allowed time range for (sun - 0300), no post check will occur.
2017-02-26 03:04:48 - DEBUG: eligible posts WP_Query Array
(
[posts_per_page] => -1
[cat] =>
[post_type] => Array
(
[0] => question-for-the-day
)
[ignore_sticky_posts] => 1
[post_status] => Array
(
[0] => draft
[1] => pending
[2] => publish
)
[order] => ASC
)
2017-02-26 03:04:48 - DEBUG: found 381 results.
2017-02-26 03:04:48 - DEBUG: processing post Where can I find humor in my life right now?
2017-02-26 03:04:48 - DEBUG: wp_update_post Array
(
[ID] => 1252
[post_status] => publish
[post_date_gmt] => 2017-02-26 08:04:48
[post_date] => 2017-02-26 03:04:48
)
2017-02-26 03:04:48 - POST id 1252 RECYCLED: 'Where can I find humor in my life right now?'
2017-02-26 03:05:48 - DEBUG: eligible posts WP_Query Array
(
[posts_per_page] => -1
[cat] =>
[post_type] => Array
(
[0] => question-for-the-day
)
[ignore_sticky_posts] => 1
[post_status] => Array
(
[0] => draft
[1] => pending
[2] => publish
)
[order] => ASC
)
2017-02-26 03:05:49 - DEBUG: found 381 results.
2017-02-26 03:05:49 - DEBUG: processing post How can I question myself and my daily patterns more skillfully?
2017-02-26 03:05:49 - DEBUG: wp_update_post Array
(
[ID] => 1259
[post_status] => publish
[post_date_gmt] => 2017-02-26 08:05:49
[post_date] => 2017-02-26 03:05:49
)
2017-02-26 03:05:49 - POST id 1259 RECYCLED: 'How can I question myself and my daily patterns more skillfully?'
2017-02-26 04:04:47 - DEBUG: current time 0404 is not in allowed time range for (sun - 0300), no post check will occur.
2017-02-26 05:04:48 - DEBUG: current time 0504 is not in allowed time range for (sun - 0300), no post check will occur.
2017-02-26 06:04:54 - DEBUG: current time 0604 is not in allowed time range for (sun - 0300), no post check will occur.
2017-02-26 07:04:48 - DEBUG: current time 0704 is not in allowed time range for (sun - 0300), no post check will occur.
2017-02-26 08:04:47 - DEBUG: current time 0804 is not in allowed time range for (sun - 0300), no post check will occur.
2017-02-26 08:04:52 - DEBUG: current time 0804 is not in allowed time range for (sun - 0300), no post check will occur.
2017-02-26 09:05:07 - DEBUG: current time 0905 is not in allowed time range for (sun - 0300), no post check will occur.
2017-02-26 10:04:48 - DEBUG: current time 1004 is not in allowed time range for (sun - 0300), no post check will occur.
Yes, it still looks like the WordPress cron is calling APS twice, probably for the reasons I mentioned above.
If you tried using server cron jobs, and wp-cron is not being called, you will have to figure out why at the server level. The server error logs should have something if you mis-configured the cron entry or something else occurred.
Thread Starter
Ynah
(@ynahpantig)
Hi John,
I just got it to work for my server. Here’s the cron line that fixed it (it is a bit different than the one that’s on your FAQ page the reason why I was having issues previously)
* * * * * wget -q -O - http://my.domain.com/wp-cron.php?doing_wp_cron >> /var/www/cronlog 2>&1
Instead of
*/5 * * * * wget -q -O -"http://www.mydomain.com/wp-cron.php?doing_wp_cron='date +\%s'" > /dev/null2>&1
I wanted it to run every minute because we have a lot of other things running in the background.
Thread Starter
Ynah
(@ynahpantig)
Hi John,
It looks like this issue is still happening very randomly with at least 3-4 months gap. I looked at the server error logs as you had suggested previously but there’s nothing there. The cron is running via server cron instead of wp-cron.
Any other thoughts?
I tried a google search for “wordpress cron execute twice” and found this page.
The answer mentions something you can try for the server cron job to try to avoid the cron job running twice.
Thread Starter
Ynah
(@ynahpantig)
Thanks @johnh10. I’ll look into the link and let you know how it goes.