RunCloud makes it simple to set up and run cron jobs from your dashboard, with no need to mess with any server settings. If you’d like to learn why cron jobs are necessary for WordPress, refer to our previous post.

Adding a Cron Job

Method 1: Using WP CLI

You can execute jobs easily using WordPress CLI. To schedule new jobs, go to your RunCloud dashboard and copy the root path of your web application.

Next, go to the server page and click on the “CronJob” button in the left menu. On the next screen, click on the “Add New Job” button to create a new job.

On the next screen, you can specify the details. Provide a descriptive name for your job, and in the user field, enter the name of the owner of the web application.

In the “Vendor Binary” drop-down, select (Write your own, inside command), and in the command field enter the following:

wp cron event run --path="/home/runcloud/webapps/app-connelly" --due-now

In the above command, make sure to replace /home/runcloud/webapps/app-connelly with the root path of your web application.

Finally, set the frequency of your Cron job from the drop-down menu, and then click on “Create Cron Job“.

Method 2: By Executing wp-cron.php

To add a cron job to a WordPress application on RunCloud, open the web application dashboard and take a note of the owner of the application and PHP version being used.

Next, copy the public path of the website to your clipboard. This is where the wp-cron.php file is stored.

After you have copied the path, open the “Cronjob” menu and click on the “Add New Job” button to create a new entry.

On the next screen, you can configure the job. First, provide a descriptive name to the job, and then specify the user account that will run this job on your server (owner of the application).

Next, specify the PHP version of your application in the vendor binary drop-down.

After that, you need to specify the path to cron file – simply paste the path to the public directory that we copied before, and then add /wp-cron.php after it.

Finally, you need to specify how often you want to execute this cron job. For most WordPress websites, a frequency of every 10 minutes is good enough.

Disabling WordPress’s Wp-Cron

After manually setting up the cron job on your server, you need to explicitly disable the WordPress’s cron execution. You can do this without leaving the RunCloud dashboard.

Open the “File Manager” page for your WordPress site and look for wp-config.php. Click on it to open a text editor in a new window.

Look for the line that says ‘Add any custom values between this line and the “stop editing” line.‘ and paste the following code below it:

define( 'DISABLE_WP_CRON', true );

Once you save the changes, WordPress will stop executing the default cron job on page loads.