Setting the Server Side Cron (Linux Cron)
The Server Side Cron option if one of 2 options in the Advanced settings of MailPoet to trigger the Task Scheduler. This ensures your emails are sent quickly and on time without delay.
The Server Side Cron option is ideal if you have:
- Sending issues;
- Issues with high CPU usage on your server;
- any other form of sending issues, for example your site is behind a firewall.
You can set it up in under 5 minutes even if it appears quite technical! MailPoet's support team or your host should be able to help you if necessary.
What is the Cron Option?
A “Linux Cron” is a server side script that runs frequently to trigger any task of your choice.
In this case, we are using it to trigger the MailPoet Task Scheduler every minute to make sure MailPoet sends regularly.
Changing the cron option
1. Go to your wp-admin > MailPoet > Settings. Click the “Advanced” tab.
2. Toggle the server side cron (Linux cron option).
3. With that enabled, you’ll see a new box which is the cron job you need to set on your server. That’ll look like this;
Now you have the cron URL you need to set it’s time to set it up on your host.
There are a few ways to set up a cron, and this depends both on your level of experience and the type of hosting you have.
Setting Your Cron Job
Method 1: Using cPanel
This is the most common method of setting a cron job and involves setting the cron job directly within the control panel of your hosting. Most hosts use “cPanel.” Including popular hosts such as Siteground and Bluehost.
There are detailed guides from a number of hosts including;
- Setting a cron job on Siteground.
- Setting a cron job on Bluehost.
- Setting a cron job on GoDaddy.
Of course, there are any more hosts than what is covered above, but the process when you access the cPanel of your hosting provider is the same.
Method 2: Using crontab
Crontab is for more advanced users and those with SSH access to their server. Most shared and managed hosting environments do not provide this level of access.
For more information on setting up a cron job using crontab read this excellent article created by Linode.
Why would I need to use this option?
- More control over how often the task is run.
- Stamps out high CPU usage issues on your server which can be an issue with some hosts.
- Does not run a constant background process that some hosts don’t allow.
- More reliable than using “visitors to your site” as it will run at the interval set regardless of visitors.
Troubleshooting
MailPoet will generate the command for you to configure for your Linux cron based on the location of the plugin on your server, and your root directory.
However, if you've set up the cron job and it doesn't appear to be running (i.e. emails aren't sending), then it's possible you may need to add the full path before php
at the start of the command, for example /usr/local/bin/php
The path to the PHP executable can generally be found in your hosting's cPanel > Advanced > Cron Jobs. If you are unsure about this, please reach out to your hosting support to confirm the path to use for PHP, as well as confirming the location of the file and root directory for the rest of the command.