Cron is a task management system on a server. It's a function by which WordPress handles scheduled tasks. It controls such basic functionalities as checking for updates periodically, publishing scheduled posts or automatically cancelling orders in WooCommerce after a certain time. The article explains how the WP cron works, how to disable it, and also run the WP cron manually.
Contents
What is WP cron?
WP-cron is called each time a site based on WordPress is reloaded. It is a time when the list of tasks to be performed is checked. If the system detects any of the tasks that should be executed, it will be done. Unlike the system cron, WP-cron does not check the task list at all times. The WP-cron function is only called when customers visit your website, e.g. browsing product pages.
It is normal that users do not visit your store, in the middle of the night. The sequence of tasks will not be activated if there is currently no traffic on the site.
How to execute/ run WP cron manually?
The cron triggers on the page loads. So, if there is none, the WP cron will not run leaving the scheduled tasks waiting. But, it's possible to run the WordPress cron by opening the page or adding the wp-cron.php?doing_wp_cron to the request.
If your store is not visited by many people the WP cron will not execute. If you would like to keep the task execution fully automated, follow these steps.
How to replace WordPress cron with a server cron?
Step 1: Disable the WP-cron function
Start by turning off the scripts that cause the WP-cron function to perform every time you visit your WordPress-based website. Edit the wp-config.php file located in the main directory of the site and add a line to it:
Step 2: Add a command to a server cron
Then most importantly, you should add a task to the server cron that will automatically trigger the WP-cron function every specified time. Below is a manual for the cPanel system. If your hosting uses a different management system, the steps should be similar:
Log in to the cPanel hosting management system and select Cron jobs :
In the next step, add a new cron task, giving the following sequence as a command:
Command:
Replace the phrase woo.shop.com with the address of your WooCommerce store.
Alternative: Using an external service to run the cron
If your hosting service provider does not give you the opportunity to add a cron task in the hosting management panel, you can use the free service cron-job.org. The external service works like this. The robot will automatically run wp-cron on your site every specified time. Create an account on the site and add a new task:
Enter the address in the second field:
http://woo.shop.com/wp-cron.php
Final effect
Thanks to the above steps, cron in your site will always be performed. Even when there is no traffic on your site. Thanks to this you will be sure that the cyclic WordPress core tasks and those performed by WP Desk plugins will always be performed. Some of them are:
- downloading a list of delivery points for shipping plugins
- importing products into the store using XML files
Summary
So, the cron handles scheduled tasks in WordPress, WooCommerce, themes, and plugins. Managing its proper execution may be important for the proper functioning of the site.
WP Desk Plugins →