1

My hosting company infrom me that they do not allow loopback connections, which are required to run the following cron task on my server. I need to run a cron task for this plugin:

http://tribulant.com/plugins/view/1/wordpress-newsletter-plugin

wget -O /dev/null "http://localhost/?wpmlmethod=docron&auth=XXXXXXXX" > /dev/null 2>&1

They provide the following code which I have adapted for my hosting (path to wget being /usr/bin/php I blieve).

I've also tried letting wp-cron.php do the job itself, and it fails, I've also tried making a simple server cron job that manually fires wp-cron.php, this worked once and didn't fire again. I'm now testing the latter with a longer schedule.

Ahhh! Thanks.

7
  • no don't replace wget, just change localhost to your domain name and add the command to your server cron job. And it should work. Have you tried that? Commented Jul 5, 2011 at 9:55
  • I have tried the code as is, with my URL and auth code, provided by the plugin. When I test the command on my server I recieve: "Cannot find 'wget'". If I preceed wget with usr/bin/php then it gives no error.
    – Bill
    Commented Jul 5, 2011 at 10:11
  • No, wget and /usr/bin/php are two separate commands. Can you please try the command curl? if curl is there then you can curl instead of wget. Do you have shell access on your shared hosting? Commented Jul 5, 2011 at 10:50
  • I'm now trying this... /usr/bin/php curl --silent --compressed curl mydomain.co.uk/wp-cron.php > /dev/null 2>&1
    – Bill
    Commented Jul 5, 2011 at 11:14
  • no no.. just run cur. don't prefix it with /usr/bin/php. And don't run wp-cron.php run the url plugin gave you. it should be: curl --silent "localhost/?wpmlmethod=docron&auth=XXXXXXXX" Commented Jul 5, 2011 at 11:52

1 Answer 1

2

You could just try the alternate WP Cron method, which doesn't require loopbacks.

Add define('ALTERNATE_WP_CRON', true); to your wp-config.php file.

2
  • Well, my 2 minute interval job for the plugin mentioned above is not firing using the alternate method. Is it advisible to create a server cronjob to fire wp-cron.php?
    – Bill
    Commented Jul 5, 2011 at 15:23
  • 2
    You need to understand something about wp-cron. It's not a guaranteed timing mechanism. wp-cron only ever fires based on site activity. If you have a job set to fire every two minutes, but nobody visits your site for an hour, then the job doesn't fire for an hour. wp-cron is not meant for stuff that must be done on a regular basis, and it never will be meant for that. If you have anything that must happen at a specific time, then don't even consider using wp-cron for it.
    – Otto
    Commented Jul 5, 2011 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.