Replacing WordPress WP Cron with Linux cronjob (URL and wp-cli Method)

Draft Warning

You’ve reached a draft 🤷‍♂️ and unfortunately I haven’t completed it yet. It’s coming soon!

What is the WP-Cron

The WordPress WP-Cron is used to run scheduled tasks within WordPress core, as well as plugins such as WooCommerce.

The WordPress WP-Cron will run on each page visit by a visitor, this can result in the WP-Cron running multiple times on busy sites and con under up slowing down

The WordPress cron will run automatically when a visitor visits your site. This can cause an unnecessary load on your server or slow down the single request and result in a slower load time of your site.

A popular option is to disable the automatic WordPress cron, and replace it with a manual cron. Below are two methods to achieve this.

First Step, Disable the WordPress WP-Cron From Running on Page Visits

This is required, and simple edit of your wp-config.php. Locate the following line below, and change it from false to true. You may not have it in your wp-config.php; simply add it above the line “/* That’s all, stop editing! Happy publishing. */”.

define('DISABLE_WP_CRON', 'true');

WordPress Cron using URL Cronjob

I will detail this more and the caveats.

WordPress Cron using WP-CLI Method

This is the preferred method since it will work if there are DNS and other network issues.

*/5 * * * * wp --path=/var/www/ cron event run --due-now > /dev/null 2>&1
You May Also Like
Read More

GridPane CLI Cheatsheet

General Commands Nginx Specific System Specific LiteSpeed Specific gpols site – regenerate ols configuration after modifying ols/headers.conf…