WordPress Cron Not Working
WordPress Cron Not Working
My WordPress plugins, SFS and SAC, can do some cool stuff with WP Cron. But sadly on media temple servers, WordPress Cron is not working. So after doing some research, it turns out to be a relatively common problem: various web hosts disable the functionality that is required for WordPress Cron to work. It’s kind of a bummer, but there is a relatively simple solution.
So if WordPress Cron is not working on your server, you can either switch hosts (if that is a luxury you can afford), or you can try the following quick fix.
Step 1: Add the following line to your
That’s all there is to it. This line invokes WP’s alternate cron method, which seems to work well on any server. So just add the line of code right above the line in
wp-config.php that says, “That’s all, stop editing! Happy blogging”, and you’re done. Enjoy your bowl of WP Cron.
Downside & Alternate Solutions
The downside is that every so often, the requested URL will include a long query string containing various wp-cron parameters. If you surf around this site, for example, eventually one of the URLs that you visit will look something like this (note: because of Googlebot’s aggressive crawl behavior, the domain name has been changed for the following example):
Not really that big of a deal, depending on how frequently WP Cron is running on your site. But if the occasional weird looking URLs are a deal-breaker for you, you alternately could rent a cheap server and set up a cron job, or even use a free cron service, which could fit the bill depending on your needs.
Bonus tip: you can trigger WP Cron manually by visiting the following URL:
Triggering WP Cron via the
setcronjob parameter works as expected in most cases, but I just heard from a reader, who reported the following:
“I did try to run this:
wp-cron.php?setcronjob. It would not stop, so I closed the window. Next time I logged in, I found these queries: ‘WordPress SEO Premium found that you deleted an article, click here to redirect the URL.’ About 10 notifications like that. I tried to figure out which articles were deleted, but I cannot find.”
Thank you to Dan for reporting this, it’s a good reminder. If you decide to trigger WP Cron manually, I guess just be aware that it might, in turn, trigger other scripts and plugins to execute any queued functionality. So as always, keep healthy backups of your site, test thoroughly, and always keep an eye on what you are doing.
Happy cron’ng people.
WP Cron + HTTP Authentication
Updating this post again to add: if your site is using HTTP Authentication (you know, the dialog/prompt that pops up and asks for your username and password), WP Cron will not work. This is because WP Cron does not present the proper login credentials when making the request. To help with this, I wrote a free plugin that enables WP Cron when HTTP auth is enabled. Check it out at the WP Plugin Directory: WP Cron HTTP Auth.