By default, WP Cron “fires” whenever you have a visitor on your site. This is what sends out email notifications to your members, and triggers various other website activities.

However, sometimes your website won’t have enough traffic to trigger this on a regular basis and it can be frustrating when you have things like memberships that need to be updated often.

This is where system cron or custom cron jobs come in, and there are a few options available to you as detailed in this document.

6.1 Using a Plugin or 3rd-Party Service

Copy chapter anchor to clipboard

WPMU DEV hosting environments utilize server-side crons that call the WordPress scheduling system via WP-CLI every 5 minutes to ensure your scheduled tasks run on time, every time. This eliminates the need for alternative cron usage or external services.

However, if you do need to define a custom cron job that fires more frequently than every 5 minutes on our hosting, you can use a plugin or 3rd-party service (on our Managed WordPress hosting, members do not have the root access required to modify this behavior via SSH).

The plugin method also works fine on most 3rd-party hosts to define cron jobs at any frequency you need whether or not you have root access or SSH knowledge.

Using a Plugin

There are a few Cron plugins freely available from the WordPress.org plugin repository with different setup options. For example, WP Crontrol enables you to create cron jobs using a URL or a WordPress hook, while with Get URL Cron, you can set them up to fetch a URL or fire a WordPress shortcode.

We’ll use Wp-Crontrol for this example. Once the plugin is installed and activated, go to Tools > Cron Events in your site’s wp-admin, and click on the Add New button.

Add a new cron job in WP-Crontrol

On the next screen, enter the Hook Name to use as the trigger to fire your cron event, and any optional arguments your cronjob may need. Then set the run time and recurrence schedule, and click Add Event to finish.

If your event needs to call a file or external URL, use the WordPress wp_remote_get function in the Hook Name field to fetch the file or URL; for example:
wp_remote_get( 'http://example.com/some-file.php' );

Add a new cron job in WP-Crontrol

For more information on using WP-Crontrol for your custom cron jobs, see the FAQ on the plugin’s WordPres.org page.

Using a 3rd-Party Service

There are a few 3rd-party services that can be used to create custom cron jobs, but we’ll use the free EasyCron service for this example.

Once logged into your EasyCron dashboard, click the + Cron Job button.

Add a new cron job in EasyCron

That will pop open a modal window where you’ll enter the URL to call for your cron job, set the frequency it should run, then click Create Cron Job to finish.

Add a new cron job in EasyCron

For more information on using EasyCron for your custom cron jobs, see the EasyCron FAQ and tutorials.

6.2 Using cPanel (3rd-party hosts only)

Copy chapter anchor to clipboard

If your host uses the popular cPanel interface, setting up a custom cron job is actually quite simple.

Log into your cPanel and look for Cron Jobs in the Advanced section, or enter “cron” (without the quotes) in the search box to find it.

Add a new cron job in cPanel

If the Cron Job option is not available in your host’s cPanel, try a plugin or 3rd-party service as above.

Use the Common Settings dropdown to quickly select the schedule for your cron job, or fine-tune it per your needs in each field below. Then enter the full file path to your script in the Command field, and click Add New Cron Job.

Add a new cron job in cPanel

You’ll then see your new cron job appear in the Current Cron Jobs section beneath the form.

For more information on creating custom cron jobs in cPanel, see this article on the cPanel Blog, or check out our tutorial on How to Set Up a Cron Job in cPanel Hosting.

6.3 Using SSH (3rd-party hosts only)

Copy chapter anchor to clipboard

In this chapter, we’ll go through the SSH commands you need to use in order to configure cron properly. You will need a working knowledge of how to use SSH before getting started. If you are unsure how to set up up SSH on your computer to work with your host, please contact your host directly for more information.

Note that on WPMU DEV Managed WordPress hosting, members do not have the root access required to modify cron via SSH. See Using a Plugin or 3rd-Party Service above.

In this chapter, we’ll go through the SSH commands you need to use in order to configure this properly. You’ll need a working knowledge of how to use SSH before getting started. If you are unsure how to setup up SSH on your computer to work with your host, please contact your host directly for more information.

Locating your WordPress Cron file

This is the file that is currently controlling the Cron jobs on your site. We need to locate it so that we can tell the System Cron to take over.

Usually this can be found in the WordPress installation directory. You will need to know the full path to this file, for example:
/home/username/www/public_html/wp-cron.php

You can locate this file via FTP through a program like FileZilla.

Locate wp-cron file in Filezilla

From here, you can right click on the wp-cron.php and select “Copy URL(s) to clipboard” –

Copy wp-cron URL in Filezilla

Next, you can open a simple program like Notepad to paste this URL:

Paste wp-cron URL in text file

You can go ahead and save this file just to make sure you don’t lose this file path and need to repeat these steps later.

Locating your PHP Executable

Now things get a little more complex. Remember how we mentioned earlier that you will need a working knowledge of SSH in order to configure your System Cron? This is where that knowledge comes into play.

First, open your SSH program. In this example, we are using PuTTY on a Windows PC. You’ll then need to login using your SSH credentials. If you are not sure what these are, please contact your hosting company for more information:

Log into SSH in PuTTY

Next, you’ll type in “whereis php” (without the quotation marks) and press enter:

Using whereis in PuTTY

What you’re looking for is the file path “/usr/bin/php“. If that shows up in your results, then you’re good to move onto the next step.

If that file path does not appear, then select one of the other available file paths, such as “/usr/includes/php“.

Once you’ve identified your file path, you’re ready for the next step – configuring your System Cron.

Configuring your System Cron

After you’ve identified both file paths that you need, you’ll be able to schedule the Cronjobs for your site.

To do this, enter the following command (without quotation marks) into your SSH program and press enter: “crontab -e

You’ll then be presented with the following screen:

Using your arrow keys, move your cursor to a new line, below the last entry. There you’ll input the frequency you’d like for the Cron events to occur, followed by the file paths you found earlier. The result will be something like this:

Cron result in PuTTY

The format is: [interval] space [path to PHP executable] space [path to wp-cron.php]. Make sure you include an actual “space” (not the word) after the interval and between the two file paths.

After you’ve input this command, all that is left to do is exit – your changes will be saved automatically.

For my program, I will type “CTRL + X“.

That’s it! Congratulations, you’ve successfully configured your System Cron.