cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Wordpress Wp-cron editing

I have two sites hosted by GoDaddy.  One is a wordpress site with a traditional hosting plan, the other is Managed Wordpress.  I had a problem with a plugin that was fixed by editing my wpconfig and setting up a cron job thru cpanel.  That fixed my problem.  

 

I use the same plugin with my "Managed" site and can not figure out how to remedy the same issue because I don't have cpanel access to easily adjust my wpconfig and add the needed cron job as instructed at http://www.nextscripts.com/tutorials/wp-cron-scheduling-tasks-in-wordpress/

 

Any advice?  I called GoDaddy support and they could not offer any suggestions other than helping me setup FTP access to edit the wpconfig file.  This did not help my issue.

 

The biggest problem with the plugin is that posts are being added to my site several times.  I use ifttt to automatically create a post if I like a youtube video.  Site 1 works great, managed site posts 3-4 times.  In addition, the plugin I use to automatically republish old posts works fine on site #1 after following the instructions in the link above.  I need to get this issue corrected.

 

Thanks for any help.

3 REPLIES 3
Helper III
Helper III

Re: Wordpress Wp-cron editing

I'm not an expert, so  this information might not be completely accurate.

 

To my knowledge, managed wordpress accounts do not have any way  of creating system cron jobs.  Were you able to actually edit your wp-config.php file?  If you were, then you might still be able to get something to work.

 

In my case, I disabled wp-cron in the config file, and set up a cron job to run the wp-cron.php file manually.  If you want to do something like this, you may just need to set up the cron task on another server (maybe even the server you have the traditional hosting on).  All you would need to do is run something like "wget http://(address)/wp-cron.php" - using the address of your managed wordpress server.

 

Is that helpful at all?

Helper II
Helper II

Re: Wordpress Wp-cron editing

Hi Chris,

 

Just finished researching this issue for Managed WordPress Hosting and found two working solutions for our website.

 

The Problem

Queued cron jobs just sit in the queue and never execute with Managed WordPress so various plugins do not work as they should.

 

For us these problem plugins were:

  • WP-DBManager
  • Revive Old Post (Former Tweet Old Post)
  • Wordfence Security

 

Cron Event Queue Insight

To help see what is going on and if cron jobs are running (or not) I recommend installing a cron queue control plugin that shows you all cron jobs (inside of WordPress).  Here is the one I found helpful, WP Crontrol:  https://wordpress.org/plugins/wp-crontrol/

 

Crontrol indicated that wp-cron.php was unable to spawn so the cron jobs could never run and just stacked up in the queue.

 

Solution One - Alternate WP Cron

Edit your wp-config.php file and add the argument, then FTP the edited version to your website.

define('ALTERNATE_WP_CRON', true);

This allows the alternative WordPress cron to work whenever a page visit occurs.  It also allows loopback to activate for cron jobs within Managed WordPress Hosting.  I confirmed with GoDaddy tech support that the Apache server DOES have loopback switched on as a back-end service and adding this definition will switch it on for Manged Wordpress Hosting.

 

Once activated your cron jobs will now run for all plugins successfully but beware...

 

A Big Disadvantage

The BIG disadvantage is ALTERNATE_WP_CRON sometimes appends the cron job number on the end of your URL for the person visiting a webpage, if they visit at the same time a cron job is waiting in queue to be executed.  

 

Their visit triggers the queued cron job(s), by redirecting their URL and recreating it with the appended cron job number added, so activating the queued cron job(s).

 

For example:

www.yoursite.com/yourpage/wp_xxxxxxxxxxxxxxxxx

 

Google Analytics now records your traffic no longer just to the plain /yourpage/ but additionally to

/yourpage/wp_xxxxxxxxxxxxxxxxx which really messes up your stats.

 

Additionally any social media plugins (for example, ShareThis) can pick up this crazy url if a visitor shares it using Facebook, Twitter, LinkedIn etc.

 

  

Solution Two - External Cron Job Server

The better, cleaner and more controlled way to make the cron job queue work is to use an external cron job server to fire things off every xx minutes.

 

Edit your wp-config.php file and add the argument, then FTP the edited version to your website.

define('DISABLE_WP_CRON', 'true');

 

This disables wp-cron.php from spawning but leaves the queue fully able to function, it just needs telling when to execute.

 

Now set up activating wp-cron.php from an external server at fixed intervals, by sending a GET http request.  This will activate and execute all waiting cron jobs in the WordPress queue however often you specify.

 

Here is the http url you need to send from the external cron job server.

 

http://www.yourwebsite.com/wp-cron.php?doing_wp_cron/?nocache=1

 URL Breakdown

  • You are hitting /wp-cron.php manually,
  • ?doing_wp_cron activates the cron queue,
  • /?nocache=1 sends an uncached version of the page in response.

 

Varnish No Cache (Essential Parameter)

Managed WordPress uses the server side caching program Varnish that acts in a way similar to a CDN (Content Delivery Network).

 

The essential parameter to include here is /?nocache=1 for without it Varnish will send back a cached server response for your request (after the first time running) and thereafter never activate the wp-cron.php queue inside of Managed WordPress.  Meaning the cron jobs will never run after the first time.  This part of the problem was the most confusing and frustrating to figure out.

 

Alternate Way

An alternate way of making sure a non-cached page is activated every time, is by adding a random number at the end of the http url request, for example:

http://www.yourwebsite.com/wp-cron.php?doing_wp_cron__random__

(where __random__ adds a random number using the https://www.setcronjob.com service):

 

http://www.yourwebsite/wp-cron.php?doing_wp_cron2043062781

Since Varnish never sees the same webpage url request twice, as they all have unique names, the wp-cron.php will activate every time.

 

Confirm Execution of Cron Jobs

Use Crontrol to confirm your cron jobs are now executing at the specified times the external cron job server is sending the http url requests and everything should now work just fine.

 

Hope this helps.

Aly

 

 

Re: Wordpress Wp-cron editing

I'm trying to figure out a solution for this as well. Has anyone tried Easycron? I'm curious if this would work for the managed WP?