fbpx

Wordpress

Mailpoet Cron

by , , revisited on


We have by far the largest RPM repository with NGINX module packages and VMODs for Varnish. If you want to install NGINX, Varnish, and lots of useful performance/security software with smooth yum upgrades for production use, this is the repository for you.
Active subscription is required.

Setting up Mailpoet Cron in newer versions (>= 3.11.3)

In the WordPress Admin, head over to MailPoet Settings -> Advanced.

Choose the “Server side cron (Linux cron)”, and copy-paste the command for running cronjob.

php /srv/www/example.com/httpdocs/wp-content/plugins/mailpoet/mailpoet-cron.php /srv/www/example.com/httpdocs/

Make sure to copy-paste the command as provided in your WordPress admin. The above is just an example.

Now, log in to SSH as the Linux user for your WordPress website, run crontab -e command, and paste in the command with the frequency (every minute):

* * * * php /srv/www/example.com/httpdocs/wp-content/plugins/mailpoet/mailpoet-cron.php /srv/www/example.com/httpdocs/

Exit the cron editor and you’re done.

Set up cron for earlier MailPoet versions

The below instructions apply to older versions. At one point, MailPoet developers decided for everyone that the real Linux crons brings more issues than it solves. What?

This is quite outrageous in my opinion. The true performance can be achieved ny using proper server setup and their plugin does something weird. Let’s fix Mailpoet to use Linux cron and not something custom solution they made up out of nowhere.

Disable custom Mailpoet cron

In wp-content/plugins/mailpoet/lib/Config/Initializer.php, disable comment this line:

$this->setupCronTrigger();

So it looks like this:

//$this->setupCronTrigger();

Setup Linux cron for Mailpoet

First, create the actual PHP file which will call Mailpoet cron:

<?php

// Let's load WordPress
require( 'wp-load.php' );

\MailPoet\Cron\Triggers\WordPress::run();

Next, create a Linux cron job which calls it:

* * * * * /usr/bin/php /var/www/html/mailpoet.php

That’s it. Now you can sit back and relax knowing that some crazy custom cron solution is not causing load on your server.

  1. Karen

    Hi Danila,

    If you wouldn’t mind clarifying your instructions a bit. I’m new to cron.

    1) You called your new php file mailpoet.php and created in the linux root?

    2) Could you explain this part “/usr/bin/php” and what it’s function is

    3) Can the new mailpoet cron be placed below my other, which is currently a wget mydomain wp-cron.php?doing_wp_cron >/dev/null 2>&1 inside of EDITOR=nano crontab -e

    Thanks and sorry for the rookie questions

    Karen

    Reply
  2. Danila Vershinin

    Hi Karen,

    MailPoet devs have reinstated support for native Linux cron, so things would be a bit easier.
    I have updated the post by adding the section “Setting up Mailpoet Cron in newer versions (>= 3.11.3)”.
    It applies to the latest versions of MailPoet, so you can use those instructions.

    You no longer need to create a file, just add an entry to crontab and specify that you prefer the Linux cron in the MailPoet settings.

    As for wget mydomain wp-cron.php, that is the WordPress standard cron.
    There is a better way to run it.

    When you are done with everything, you will have 2 actual cron jobs: one that calls wp-cron.php (standard WordPress), and the other for mailpoet-cron.php (MailPoet).

    The /usr/bin/php in the cron definition, unambiguously identifies the PHP interpreter for running the cron jobs. You can just specify simply php in your cron jobs if that is the only PHP interpreter installed in the system and its path is in the system path.

    Reply
  3. Karen

    Thanks Danila!!!

    I really appreciate the help! Especially updating your post and providing a better way to do cron. I’ll look into that now.

    Thank you

    Karen

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.