What is WordPress?

WordPress is the foremost open-source web application globally, cherished for its user-friendly interface, extensive customizability, and robust community support. It boasts many built-in features that streamline website creation, with one notable capability being its seamless execution of web tasks sans manual intervention.

What is CRON?

In WordPress, “cron” refers to the ingenious system for automating scheduled tasks without manual intervention. Short for “command run on,” it enables WordPress to execute various actions automatically, like publishing scheduled posts, updating content, and running plugin functions.

WordPress utilizes its built-in cron system, often called “wp-cron,” which triggers tasks whenever visitors access the site. Unlike traditional cron jobs tied to server schedules, wp-cron ensures tasks are performed dynamically, even during low-traffic periods.

Optimizing wp-cron is crucial for ensuring timely task execution, especially for high-traffic websites. Configuring WordPress settings may enhance reliability and efficiency, ensuring essential functions are executed seamlessly.

How to Enable CRON job in WordPress.

To Enable to CRON job in WordPress follow the below steps.

  1. Accessing WordPress Files: Use an FTP client or file manager provided by your hosting provider to access your WordPress site’s files. To enable the CRON job in WordPress you can access wp-config.php using any IDE sublime text, Vs code, etc.
  2. Locate wp-config.php: Look for the wp-config.php file in the root directory of your WordPress Site.
  1. Edit wp-config.php: Right-click on wp-config.php and choose the option to edit it. You can use a plain text editor like Notepad or a code editor like Visual Studio Code or Sublime Text.

  1. Define CRON Job: Inside the wp-config.php file, add the following line of code just before the line that says “/* That’s all, stop editing! Happy blogging.
    • */":phpCopy code define('DISABLE_WP_CRON', false);
  2. This line ensures that the WordPress internal CRON system is enabled.

  1. Save Changes: Save the changes you made to the wp-config.php file and close the editor.

How to disable the internal WordPress cron feature and enable CRON from the cPanel.

  1. Accessing Hosting Control Panel: Log in to your hosting control panel. The interface may vary depending on your hosting provider, but most panels have a section for CRON jobs or scheduled tasks.

First, you need to disable WordPress CRON define('DISABLE_WP_CRON', true); in wp-config.php.

  1. Setting up External CRON Job: Locate the CRON jobs section in your hosting control panel. Click on it to create a new CRON job.
    • Configuring CRON Job: In the CRON job configuration, you’ll need to specify the command to trigger the wp-cron.php file. Use the following command:bashCopy code wget -q -O - https://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1 Replace “yourdomain.com” with your actual domain name.
  2. Setting Frequency: Choose the frequency at which you want the CRON job to run. You can set it to run every hour, every day, or at a custom interval depending on your requirements.
  3. Save CRON Job: Once you’ve configured the CRON job, save the settings.