Fairly often, I run across users who are having trouble on their site with WP_Cron. From cheap hosting to low traffic sites, it can really cause trouble for anything needing a reliable schedule where they can run tasks.
I recently ran across a way to replace wp_cron with an external service. I gave it a try on my Subscriptions test site and it worked beautifully so I wanted to pass this along in case it could help anyone. Here’s how it works.
1. Disable WP_Cron. Edit the
wp-config.php file and add this constant to it:
That will keep wp_cron from running on the site. To get the full impact of this, don’t visit the site before disabling it. That way you can see everything run later on.
2. Create an account at cron-job.org. This service can send requests to a specific URL on a set schedule. There are other services that can do this, but this one is free.
3. Set up your first cron job. You can give it a title to keep track of what it’s doing. That’s helpful if you’ll be doing this for multiple sites.
The address should follow this format. Just replace
https://site.com with the URL to your site.
For the schedule, you can set it to run as often as you’d like. Every 15 minutes is probably frequent enough.
That’s it. Really. When I tested this on my subscriptions site, I had quite a few actions that hadn’t run because no one had visited the test site that day. I disabled wp_cron and then opened up WP Control to see what was scheduled. There were lots of actions that would have run if I had just opened up the site. With wp_cron disabled, they didn’t run when I opened up a page.
I waited for the first running of the cron I set up and voila it ran wp_cron on my site. Essentially all it does is fetch the URL you give it on a schedule. Here’s what WP Control showed when I first visited the test site today.
All the events were already up to date. Nothing was waiting on traffic from a visitor to trigger them. WooHoo!
If you’re struggling with having wp_cron run reliably on your site and you don’t have access to system cron, this may be a good solution for you.