How to Disable Wp-Cron and Replace It with A Real Cron Job

How to Disable Wp-Cron and Replace It with A Real Cron Job

WordPress uses a workaround file called wp-cron.php as a virtual cron job or scheduled task for automating things like publishing scheduled posts, checking for WordPress plugins and theme updates, sending email notifications etc. WordPress setup a call to wp-cron.php every time someone loads your WordPress website. It checks if there is a scheduled task to be done and executes if necessary.

In some cases, the wp-cron.php file may become the target of DDOS attacks or it may interfere with the caching plugins which can cause a lot of server load or improper working of the scheduled task execution. So it is necessary to disable and replace this with a real cron job.

 

Linux Cron Job vs. WP-Cron

Linux cron jobs can be controlled by the user that allows you to run scheduled tasks on your web server. It is useful when a WordPress website is high a traffic, the Linux cron job can assists with reducing the chances of downtime by lowering the bandwidth of the server, thus using fewer server resources.

wp-cron.php as a virtual cron job that only works when the page is loaded. wp-cron is first loaded by WordPress when a website page is requested on the front end or backend which displaces the necessary page to the visitor.

 

Disable wp-cron.php

You can disable wp-cron by modifying the file wp-config.php inside the folder in which the WordPress is installed. Open wp-config file and add the following code

define(‘DISABLE_WP_CRON’, true);

 

Setting Real Cron Job

1) Login to cPanel.

2) Navigate to “Cron Jobs” under “Advanced” section.

Disable wp-cron

 

3) Add the following command to be executed every 30 minutes:

wget -q -O – http://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1

Replace yourdomain.com with your actual website name.

Cron Job

 

4) Click on the button “Add New Cron Job”.

 

If you need any further help, please do reach our support department.

 

 

Leave a Reply