Author Topic: Cron problem on a wordpress installation  (Read 1370 times)

Offline Upperholme

  • Ask me questions
  • ****
  • Posts: 441
  • Karma: 4
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Cron problem on a wordpress installation
« on: May 23, 2012, 03:05:57 am »
I have a Civi 4.1.2 install working on Wordpress. I can trigger scheduled jobs manually.

I have set up a cron job via the host's cpanel. the cron job looks like:

Code: [Select]
*/10 * * * * wget -O - -q -t 1 --post-data='name=username&pass=password&key=sitekey' http://www.example.com/wp-content/plugins/civicrm/civicrm/bin/cron.php
(where username, password, site key and domain are replaced with the real values).

The cron job fires and generates the following error:

Code: [Select]
Fatal error:  Call to undefined function is_admin() in /home/user/public_html/example.com/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/Base.php on line 49
This is how I've always set up cron jobs for CiviCRM, and it's always worked for me. Given the new approach to scheduled jobs, does this not work any more?

If I try to run the cron script from the browser, using:

Code: [Select]
http://www.example.com/wp-content/plugins/civicrm/civicrm/bin/cron.php&name=username&pass=password&key=sitekey
Then the site gives me a 404 error.

Where am I going wrong?

**UPDATE: Just spotted the error in the URL above - should be /cron.php?name=… rather than /cron.php&name=…

This now also gives me the same Fatal error:
Code: [Select]
Fatal error:  Call to undefined function is_admin() in /home/user/public_html/example.com/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/Base.php on line 49
Thanks
Graham
« Last Edit: May 23, 2012, 03:15:22 am by Upperholme »
Graham Mitchell
http://mc3.coop

Offline Upperholme

  • Ask me questions
  • ****
  • Posts: 441
  • Karma: 4
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Cron problem on a wordpress installation
« Reply #1 on: May 23, 2012, 03:19:46 am »
Just come across the bug report at http://issues.civicrm.org/jira/browse/CRM-9727 which suggests that this issue was fixed in 4.1.1?
Graham Mitchell
http://mc3.coop

Offline CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1222
  • Karma: 112
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.4
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Cron problem on a wordpress installation
« Reply #2 on: May 24, 2012, 09:46:02 am »
Quote
http://www.example.com/wp-content/plugins/civicrm/civicrm/bin/cron.php&name=username&pass=password&key=sitekey

Is the method I am using.  However, your cron is missing the ? after .php

Regarding Wordpress, there is good reason to keep your Wordpress updated to the latest version to avoid getting hacked.  Unless there is a compelling reason to lag behind the latest Wordpress stable version, please upgrade.
« Last Edit: May 24, 2012, 09:47:50 am by Stoob »
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Offline Upperholme

  • Ask me questions
  • ****
  • Posts: 441
  • Karma: 4
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Cron problem on a wordpress installation
« Reply #3 on: May 24, 2012, 09:54:43 am »
Thanks Stoob. I fixed the ? issue and still getting the fatal error, so we can rule that out.
Graham Mitchell
http://mc3.coop

Offline CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1222
  • Karma: 112
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.4
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Cron problem on a wordpress installation
« Reply #4 on: May 24, 2012, 10:25:21 am »
Upgrade Wordpress.

This disable all plugins but CiviCRM.  See if it works then.
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Offline Upperholme

  • Ask me questions
  • ****
  • Posts: 441
  • Karma: 4
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Cron problem on a wordpress installation
« Reply #5 on: May 25, 2012, 02:15:05 am »
I've upgraded to Wordpress 3.3.2. The only active plugin is CiviCRM 4.1.2. When attempting to call the cron script via URL in a browser, using:

http://www.example.com/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=username&pass=password&key=sitekey

where the user has the Administrator role, I get:

Fatal error: Call to undefined function is_admin() in /home/user/public_html/example.com/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/Base.php on line 49

I'm going to test this in a clean install and see if I can replicate it.

Any thoughts on what else might be getting in the way of this working? We seem to have ruled out all the obvious suspects.

Thanks
Graham
Graham Mitchell
http://mc3.coop

Offline Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15794
  • Karma: 464
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Cron problem on a wordpress installation
« Reply #6 on: May 25, 2012, 08:45:31 am »

i just tried the same thing on my local sandbox to see if i could reproduce, but did not get the fatal error

i would double check your civicrm version / code and ensure that the code files are all copied over from a 4.1.2 install

lobo