CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • CiviMail installation and configuration (Moderator: Donald Lobo) »
  • Cron problem on a wordpress installation
Pages: [1]

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

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Cron problem on a wordpress installation
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

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Cron problem on a wordpress installation
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

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • 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
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.

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Cron problem on a wordpress installation
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

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • 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
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.

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Cron problem on a wordpress installation
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

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • 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
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
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • CiviMail installation and configuration (Moderator: Donald Lobo) »
  • Cron problem on a wordpress installation

This forum was archived on 2017-11-26.