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 »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Cron not working
Pages: [1]

Author Topic: Cron not working  (Read 872 times)

Shai

  • I post frequently
  • ***
  • Posts: 202
  • Karma: 8
    • Content2zero
  • CiviCRM version: 4.3.x, 4.4.x, 4.5.x
  • CMS version: Drupal 7
  • MySQL version: 5.5.x
  • PHP version: 5.3.x, 5.4.x
Cron not working
April 10, 2013, 08:45:49 am
I can't seem to get cron working after my upgrade from 4.1.6 to 4.2.9. The Drupal version is: 7.22.

The server's cron email reports the following:
Quote
ERROR: You need to send a valid key to execute this file. More info at:http://wiki.civicrm.org/confluence/display/CRMDOC/Managing+Scheduled+Jobs

The key I'm using comes from civicrm.settings.php.

Here is the cron job I have been using (password and key have been changed from the real ones, "example.com" has been substituted here for the real site name).

/usr/bin/lynx -source https://example.com/sites/all/modules/civicrm/bin/cron.php?name=cividrupaluser&pass=axld506thedD3&key=c1fec16a3fc1479fd3150b1567b23139

(For those who know that lynx default settings have trouble with https, know that I've adjusted those settings and the problem is not related to lynx and https.)

Thanks,

Shai
Don't miss out! Sign up now for free expert advice on CiviCRM's new StackExchange help site.

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Cron not working
April 10, 2013, 10:37:54 am
Try changing the key in both civicrm.settings.php and also the cron job? Just as a test...
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Shai

  • I post frequently
  • ***
  • Posts: 202
  • Karma: 8
    • Content2zero
  • CiviCRM version: 4.3.x, 4.4.x, 4.5.x
  • CMS version: Drupal 7
  • MySQL version: 5.5.x
  • PHP version: 5.3.x, 5.4.x
Re: Cron not working
April 11, 2013, 11:57:43 am
Here is how I got it to work:

I couldn't get cron via http to work, so I tried the cli method.

I also tried this in a cron tab and and it returned the message, "You can only run cli from the command line."

/usr/local/bin/php /home/tsc/public_html/sites/all/modules/civicrm/bin/cli.php -u drupaluser-with-civiperms -p password

So then I created a script using exec, which emulates the command line. I called that file civicrm-cron.php. It's contents were:

<?php
exec('/usr/local/bin/php /home/tsc/public_html/sites/all/modules/civicrm/bin/cli.php -u drupaluser-with-civiperms -p password  -e Job -a execute');
?>

Then I created a cron job using this command: /usr/local/bin/php /path/to/civicrm-cron.php

That was the magic.

For anyone trying to use this recipe, note you need to replace drupaluser-with-civiperm with the username of a drupal user who has CiviCRM permission and of course replace "password" with the password of that person. In addition, "/usr/local/bin/php" is the path to php on my server, but the path might be different on yours. When I'm actually in the command line, I can just type "php" without the explicit path. But, at least on my server, "exec" isn't so smart and needed the explicit path.

One final warning. Your server administrator may not allow you to use the "exec" command in a script. It is often on a black list of php commands which are disabled for security reasons. You may be able to convince your server administrator to turn it back on.

Shai Gluskin
Don't miss out! Sign up now for free expert advice on CiviCRM's new StackExchange help site.

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Cron not working
April 11, 2013, 12:01:13 pm
Quote from: Shai on April 11, 2013, 11:57:43 am
One final warning. Your server administrator may not allow you to use the "exec" command in a script. It is often on a black list of php commands which are disabled for security reasons. You may be able to convince your server administrator to turn it back on.

You can also try the PHP comment system. Does the same thing. :)
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Shai

  • I post frequently
  • ***
  • Posts: 202
  • Karma: 8
    • Content2zero
  • CiviCRM version: 4.3.x, 4.4.x, 4.5.x
  • CMS version: Drupal 7
  • MySQL version: 5.5.x
  • PHP version: 5.3.x, 5.4.x
Re: Cron not working
April 11, 2013, 12:08:52 pm
@Herschel,

1. I'm either not getting the joke you made, and feel stupid...

or

2. I'm not getting how you can use the php comment system to emulate the command line in a php script.

Either way I feel stupid. Either way please explain!

Shai
Don't miss out! Sign up now for free expert advice on CiviCRM's new StackExchange help site.

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Cron not working
April 11, 2013, 01:08:45 pm
Quote from: Hershel on April 11, 2013, 12:01:13 pm
You can also try the PHP comment system. Does the same thing. :)

Typo, sorry. I meant to say the "command system" meaning PHP has a command called system http://php.net/manual/en/function.system.php that does virtually the same thing as exec.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Cron not working

This forum was archived on 2017-11-26.