Thursday 4 November 2010

WORDPRESS: Updating FEEDWORDPRESS by a real CRON Job..

The Background:

I have a Wordpress site (Supercars-For-Sale.Com) running on a free hosting account (with x10hosting - recommended!)

The site uses FEEDWORDPRESS to pull in posts from RSS feeds. It works well.

The problem:

I need the site to automatically update it's posts from the RSS feeds, because I don't have the time to do it manually.
If I set FWP to automatically update (using Wordpress inbuilt scheduling, WP-Cron), the only options are:
- Update before page load (Catastrophic page load times!)
- Update after page load (checks for jobs after every page load..)

Setting either one of these options will get you suspended on x10hosting or 000webhost free accounts.
Rightly so, these are shared servers, and you are hogging them!
(000webhost will CANCEL your account without warning - beware :( . x10hosting will suspend you, but at least they'll tell you about it :) , and unsuspend you on request.)

The solution:
FEEDWORDPRESS has an additional feature: update via web page.
If you send a request to: http://domain-name?update_feedwordpress=1 then all your syndicated input feeds are updated.

To make this work, all you need to do is set up a cron job (Scheduled task), that executes the following statement:
/usr/bin/curl --silent http://domain-name?update_feedwordpress=1

** Don't panic! a "Cron Job" is how a web server (Unix) runs scheduled tasks. You add jobs to it, tell it what to run and how often, and that's it.
"curl" is simply a command that accesses web pages from the command line.
Most webservers will have curl installed. **

x10hosting uses the cpanel graphical interface for everything. Even Cron jobs. Simply set-up the scheduling, enter the command, and that's it. (If it says there was a problem, try it again. It'll then say that the job already exists. Hit F5 to refresh, and the job is there..)

If you are using command-line crontab, then use the following statement:
*/HOURS * * * * /usr/bin/curl --silent http://domain-name?update_feedwordpress=1

Notes:
1. Replace "HOURS" with the number of hours between updates.
2. Replace "domain-name" with YOUR domain-name.

Other things to try:
If you are on a free hosting account, you could try turning off the inbuilt WP-CRON system. It's rubbish anyway, and only checks for jobs exactly when you don't want it to. (just before, or after a pageload). All you need is a big bot visit, and it's Hello, account suspension again. Been there. Done that to death
Simply edit the WP-CONFIG.php file, and add the following entry:

define('DISABLE_WP_CRON', true);

It needs to be at the beginning of the file, with the other "define"s.
** Please note that this will disable all WP_CRON activity. No scheduled jobs will run. (future-dated posts will not appear).

3 comments:

  1. great work....i will surely give a try...was facing this problem since last week..thnx

    ReplyDelete

  2. Hello,

    we provide affordable and result-oriented SEO services, please give a chance to serve you.


    Thanks
    Admin: E07.net

    ReplyDelete