How to Replace the WordPress Cron with a cPanel Cron Job

Learn how to replace the WordPress Cron with a Cron Job in cPanel. We recommend disabling the standard WP Cron and replacing it with a real cron job in your cPanel to improve site performance and help protect you from WordPress DoS attacks.

What is WP Cron?

To tackle the problem of how to run scheduled events without getting the user to setup a cron job, the WordPress Developers have added a file in the main WordPress folder called wp-cron.php. Every time someone visits a page on your WordPress site, wp-cron.php runs and checks to see if any scheduled events need to run, mimicking how a real cron job works.

Why replace WP Cron?

One of the fantastic features of WordPress is it’s ability to run across multiple different operating systems and easy setup. WP-cron is one example of the WordPress Developer’s ingenuity. In theory this sounds like a good idea, however wp-cron.php has a few problems.

  • Unlike a real cron job, WP Cron requires a visitor on your site to trigger any scheduled events. So if you don’t have a visitor on your site at the time the cron command is due to run, it will not be triggered.
  • WP-Cron is also loaded every time a page is viewed, meaning it’s an easy target for Denial of Service (DoS) attacks against your WordPress website. This can lead to slow loading pages and downtime during an attack.
  • We also occasionally see compatibility issues with WordPress plugins such as caching plugins which change the way pages are loaded. This can result in WP Cron not running at the expected times.

The answer to the above problems is to disable WP Cron and replace it with a real Cron Job in your cPanel.

How to replace WP Cron with a cPanel Cron Job

  1. To begin, you need to disable WP Cron from running each time someone visits your site. To do this, open your wp-config.php file in your main WordPress folder and add the below code at the end;

 

1
define('DISABLE_WP_CRON', true);

 

  1. Log in to cPanel.
  2. In the Advanced section, click Cron jobs.
  3. Locate Add New Cron Job. The cPanel Cron jobs tool has a number of common schedules preset. To execute the command every every 30 mins, select Twice an hour from the Setting drop down. Beta Host recommends that you do not set the interval lower than 15 minutes.
  4. Add the following command. Replace https://www.example.com with your site’s domain;
    wget -q -O – https://example.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1 :
  5. Click Add New Cron Job to set the cron.
  • wp cron, cron, WordPress, wordpress cron
Помог ли вам данный ответ? 1 Пользователи нашли это полезным

Связанные статьи

How to Manage Bandwidth Limit Exceeded and Avoid Account Suspended on WordPress

Dear Value Customer,Due to Bandwidth Limit Exceeded with Most of Our Customer that are using...

"Error Establishing a Database Connection" in WordPress

In this article we will look how to resolve the "Error Establishing a Database Connection". There...

How to use Jetpack / WP Super Cache with WordPress?

Beta Host Limited servers block remote connection to xmlrpc.php or, wp-cron.php for security...

How to Bypass Beta Host WordPress Login Security?

Beta Host Limited servers have wordpress bruteforce protection, so you may see a POPUP...

How To Get 3000 Backlinks In One Day

Backlinks are one of the most important components of having a successful website therefore we...