6. How to use System Cron
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.
The solution is to use the System Cron in order to trigger these events automatically, at certain intervals. Some hosts have a special Cron tool to use that makes this really quick and easy to setup, for others you’ll need to do this action manually via SSH.
In this tutorial we will go through the commands you need to use in order to configure this properly. You will 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.
6.1 Locating your WordPress Cron fileLink to chapter 1
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:
You can locate this file via FTP through a program like FileZilla.
From here, you can right click on the wp-cron.php and select “Copy URL(s) to clipboard” –
Next, you can open a simple program like Notepad to paste this URL:
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.
6.2 Locating your PHP ExecutableLink to chapter 2
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:
Next, you’ll type in “whereis php” (without the quotation marks) and press enter:
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.
6.3 Configuring your System CronLink to chapter 3
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:
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. Go out and celebrate!
6.4 Additional InformationLink to chapter 4
Do you have any questions about the steps in this guide? Or would you like some additional information about WordPress Cron and how this could effect your site?
If so, please head over to our support page, and open up a live chat to discuss this with our team.