0

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 ...

  • WP Cron jobs only run when there are actively visitors on your site. Have you checked to see whether anyone is visiting? – WebElaine Feb 4 at 18:17
  • How are you testing that these cron jobs get run? Are you sure they didn't run and get replaced by identical ones? Have you tried manually running cron jobs using WP CLI and seeing what happens? Are you sure that your cron jobs don't trigger fatal errors? – Tom J Nowell Feb 4 at 18:38
  • @TomJNowell: I run "manually" the executable function and get no errors - it goes through with no issues. I know no cron jobs are running, because I log errors and expect to see those logs in my debug.log. I edited other cron jobs in order to test like the "wp_privacy_delete_old_export_files" and get the same result. As said, those schedules 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. So, I am trying to find out what can be causing this on the online server. – FFrewin Feb 4 at 20:05
  • what happens if you manually visit the wp cron PHP file? – Tom J Nowell Feb 4 at 20:09
  • @TomJNowell. No cron job function is executed on the online server. - Cron functions run as expected on localhost (by going to /wp-cron.ph) – FFrewin Feb 4 at 20:29
-1

Some hosts (Especially shared servers) don't allow Cron Jobs as it can 'supposedly' slow their servers down.

I'd send them a ticket to ask.

  • Try to run iThemes backup buddy on Heart Internet. You'll see I speak da truth :D – Electronic Ink Feb 5 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.