0

I use Ubuntu 20.04 LEMP stack VPS. In this server, I run 13 WordPress sites. Every 10 minutes I have set up to run each site cron job with a 20 seconds interval. So every site does not execute cron jobs exact same time.

I edited crontab using the following command.

crontab -u www-data -e 

When I go to the WordPress cron event plugin page, it shows The DISABLE_WP_CRON constant is set to true. WP-Cron spawning is disabled.

What is WP-Cron spawning? and can I enable it while using define('DISABLE_WP_CRON', true);

my crontab script sample.

while ! wget -q -O - https://example.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1 ; do sleep 2 ; done ; echo ok

enter image description here

1 Answer 1

3

What is WP-Cron spawning?

First off, let's see what WP-Cron is and how it works:

  • WP-Cron is how WordPress handles scheduling time-based tasks in WordPress, e.g. checking for core updates and publishing scheduled post.

  • WP-Cron works by checking, on every page load, a list of scheduled tasks to see what needs to be run.

  • Any tasks due to run will be called during that page load.

    And at this point, a cron spawning might happen, whereby WP-Cron would send a request to run cron through HTTP request that does not halt page loading. And note that the request is sent to wp-cron.php, e.g. https://example.com/wp-cron.php.

So WP-Cron spawning is basically an automatic cron call that happens on page load. See _wp_cron() and spawn_cron().

Therefore, if you manually run WordPress cron, then you should disable the automatic cron call since it will contribute to extra resource usage on your server. See Hooking WP-Cron Into the System Task Scheduler.

And thus, there should be no need to worry regarding the message that says WP-Cron spawning is disabled — it is probably merely a notice/reminder, or that the plugin might simply be trying to make a test cron request, but then did not proceed when it noticed WP-Cron spawning is disabled.

Nonetheless, if the spawning is disabled, then ensure that WordPress cron is still being executed properly, e.g. via the cron daemon in Linux and MacOS systems.

can I enable it while using define('DISABLE_WP_CRON', true);

WP-Cron spawning is enabled by default, but it can be disabled/enabled via the DISABLE_WP_CRON constant:

  • Disables cron spawning — define('DISABLE_WP_CRON', true);
  • Enables cron spawning — define('DISABLE_WP_CRON', false);

However, if you have access to the system's task scheduler (to make a web request to the wp-cron.php file), then you should just disable WP-Cron spawning.

3
  • sally-cj thank you for your details reply. Yes, my WordPress cron jobs run without any issue.
    – Chathu
    Apr 8, 2022 at 16:59
  • 1
    Then, as I said in my answer, you can ignore the notice which says WP-Cron spawning is disabled.
    – Sally CJ
    Apr 8, 2022 at 23:30
  • 1
    But that notice is a plugin-specific notice, so if you want to know for sure why exactly the plugin displayed the notice, please ask on the plugin's support forums. As for your main question (what is WP-cron spawning), if my answer answered that question, I'd appreciate if you can mark my answer as correct.
    – Sally CJ
    Apr 8, 2022 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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