Cron Job: Replace with a Server-side Cron Job (cPanel)

Please visit Cron Job: Basics & Checklist to learn about FluentCRM’s scheduled events, basics, and more information first.

In the Cron Job: Basics & Checklist guide, we have seen the importance of configuring a Cron Job for a WordPress Website to ensure that the scheduled jobs run timely and successfully and do not fail the scheduled jobs or events and everything works in order. This includes running FluentCRM Email Processing, Sending, Running Automation, Email Sequences, and other processing tasks.

Prechecks #

Before we begin, please make sure that you have read about the Cron Job: Basics & Checklist and event recurrences of FluentCRM and also followed Disable Default WordPress Cron System with the code below:

/* Add any custom values between this line and the "stop editing" line. */

define('DISABLE_WP_CRON', 'true');    // Disable the default PHP-based Cron invocation.

/* That's all, stop editing! Happy publishing. */

Cron Jobs or Scheduled Jobs can be run or invoked locally and remotely. In this article, we will learn about the recommended and most effective method for configuring a cron job for a WordPress Website. We also have a few articles focused on running cron jobs remotely:

1. Cron Job: FluentCRM Cron with Cron-job.org
2. Cron Job: FluentCRM Cron with EasyCron

Configure WordPress Cron Job from cPanel #

One of the most used and popular Web Hosting Control Panels is cPanel and we will be evaluating it in this article.

Find WordPress Installation Directory #

We need to find the WordPress Installation directory first where the Cron Script wp-cron.php file is located and will be needed in the further steps. You can find your WordPress Installation Directory easily by going to WordPress Dashboard ⮕ Tools ⮕ Site Health ⮕ Info Tab ⮕ Directories and Sizes Section. More about this can be found here: Find WordPress Installation Directory

crm get wordpress directory

Identifying Cron Command #

From our cPanel-hosted website, we got the WordPress Directory as below:

/home/regiktux/ibrahimsharif.com

The WordPress Cron path is:

/home/regiktux/ibrahimsharif.com/wp-cron.php

Cron Settings #

Now please go to the Cron Jobs option as shown below:

cpanel cron jobs (1)

This will offer some input fields to set the Cron Intervals and the Cron Command as below:

cpanel cron settings (1)

Most of cases, the suitable recommended time interval for running the Cron job is per minute. Putting a Star(*) means EVERY. Here all 5 stars mean Every Minute on Every Hour on Every Day on Every Month on Every Weekday.

The command for running WordPress is including the PHP Binary:

/usr/bin/php /home/regiktux/ibrahimsharif.com/wp-cron.php

And the total command including time intervals which is the resulting final output is:

* * * * * /usr/bin/php /home/regiktux/ibrahimsharif.com/wp-cron.php

Discarding Cron Command Output #

As we just run the command it showed us an output that we do not need or should discard through running the Cron Job. Our Original Command is:

/usr/bin/php /home/regiktux/ibrahimsharif.com/wp-cron.php

Now we can discard the output by sending the output to NULL adding /dev/null 2>&1 to the end. The final command including time intervals is:

Please use your own Paths and Paramaters obtained from your hosting as guided here.

* * * * * /usr/bin/php /home/regiktux/ibrahimsharif.com/wp-cron.php > /dev/null 2>&1

This does not output anything but does the job silently as shown below:

cpanel cron discard output (1)

Compare Cron Status #

When the cron configuration is completed we should check back after one or more hours from the FluentCRM Settings > Tools and compare our results against the below screenshot which is a normal FluentCRM Cron Status running 3 events on 1 Minute, 5 Minutes, and 1 Hour Intervals.

crm cron status

That’s all for cPanel WordPress Cron Configuration! Thanks and enjoy working with WordPress Scheduled Events.

3 Comments

  1. Thanks for sharing this awesome guide. I have replicated the settings for Cloudways and it’s working. I’m trying to figure out how to do this on Bunnyshell, as I have several websites hosted on this platform. I’ll share the settings here once I’ve figured it out.

  2. I search soooooo long cause they don’t work for me!!! 😅😅

    I’m with Godaddy WordPress hosting. the: define(‘DISABLE_WP_CRON’, ‘true’); don’t work!

    Don’t know why but the sentence to write properly for Godaddy is :

    define( ‘ALTERNATE_WP_CRON’, true );

    Now they perfectly work! Hope I will help person cause by my side I searching for the solution a few hours/day!! 😊 Bye bye !

Comments are closed.