You can configure WordPress to disable internal cron, and configure your server to use server cron to trigger WP cron. Every hosting company usually has information how to do that, depending on cron system they run.
Hi Milan, thank you for your suggestion!
Actually, we already use the server cron to run wp-cron.php every 15 minutes.
Problem is that we need to run the mail queue every minute.
Running wp-cron.php so often is not a good idea, because wp-cron.php contains all plugins jobs, which are CPU consuming.
The solution would be a simple PHP file that loads GD Mail Queue and processes the mail queue… or an API endpoint that does the same. would this be hard to achieve?
Thank you,
Guido
Running a mail queue every minute is also not a good idea. And, the advantage of wp-cron is the internal locking system that prevents duplicated runs in a short period. If you want to run mail queue differently, you need to implement similar locking and other logic around it.
And, there is no difference in how you run server to wp cron. WP has jobs scheduled to run at specific intervals, so even if you lower that from 15 minutes to 5, it will have no negative impact, because what WP does depends on the scheduled jobs, not how often you call it. And, if there are more jobs waiting, if you run longer intervals, it can have negative effect that more jobs will get to execution due to a longer interval.
I run 5 minutes server cron on all my servers, and I never had issues. I had issues with 2 minutes crowns, and I don’t advise that for anything, including mail sending. 4 or 5 minutes is enough.
Milan
Thank you Milan for your explanation, especially the part about how WP cron handles the schedule.
We will try setting the frequency of wp-cron.php to 2 minutes, hoping no issues will come up.
That said, please consider the following idea.
Have you considered that once you implement:
- A cron job script which is independent from wp-cron
- Job locking, for example using Jobby, or flock or a mechanism similar to WP All Import
then, maybe, and I stress maybe, the issues you experienced with 2 minute crons will be solved?
I am asking this because nowadays, 5 minutes to deliver an email may not be good enough. As a web marketing agency we often make lead generation campaigns that hand out discount coupons. If you make a customer wait 5 minutes to receive his/her coupon, you are likey to lose the conversion.
This happens because online buying is often impulsive and compulsive: making the customer wait is never a good idea.
Anyway, thank you for your time an feel free to close the “ticket” 🙂
Guido
Thanks for the suggestion. I will add this to the list, but I can’t promise that it will be done, or when it will be done. Anything dealing with cron requires a great deal of testing, and large number of systems to test with.