I wrote a plugin that uses WP-Cron to fetch periodically json data from another server. Everything works flawlessly in my localhost. However, when I uploaded the whole WP site on an online server for testing, the whole WP-Cron ecosystem seems to fail.
None of any of the wp-cron jobs ever running - including that from my plugin and core jobs like "wp_privacy_delete_old_export_files
".
Cron Jobs have been scheduled, as shown by the output of _get_cron_array()
... but none of the executable functions related to them will ever run.
After digging and debugging, I just found out that all those cron jobs are scheduled as next run for a time in the past, and that their next-scheduled time will never get updated to a future time.
Has anyone ever encounter a similar issue? What can be the possible issues for this?
Updates to include information from the comments:
I run "manually" the executable function and I get no errors - the function goes through and completes its tasks with no issues.
I know that no cron jobs are running at all, because I log errors and expect to see those logs in my debug.log. I even modified other cron jobs, even core ones like the "wp_privacy_delete_old_export_files", in order to test if those are running, and I get the same result.
All future scheduled-times for all cron jobs are set for a time in the past, and they never get updated.
The exact same code runs on my localhost and I can see the scheduled time to be updated every so, after refreshing.
Finally, accessing the /wp-cron.php also fails on the online server, while it causes all the scheduled cron jobs to run on my localhost. I guess, this is because on the online server, all jobs are scheduled for a time in the past that will never happen again in the future.
It looks like all those jobs just got scheduled on the first ever run, and never re-scheduled ...