4

I've tried different ways to setup cron jobs.

When using that cron job, the file is not able to read the parameters (like key, etc.)

/usr/bin/wget -O - -q -t 1 http://www.site.org/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=XXXX&pass=XXXX&key=XXXXX

The e-mail I received says: ERROR: You need to send a valid key to execute this file.

When using those cron jobs, they are not running:

/usr/bin/wget -O - -q -t 1 'http://www.xxxx.org/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=XXXX&pass=XXXX&key=XXXXX'

/usr/bin/wget -O - -q -t 1 "http://www.xxxxx.org/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=XXXX&pass=XXXX&key=XXXXX"

When working with php-cli:

php /home2/xxx/public_html/wp-content/plugins/civicrm/civicrm/bin/cli.php -s xxxxx.org -u XXXX -p XXXXX -e Job -a execute

The PHP error log says:

PHP Fatal error: cli.php can only be run from command line. in /home2/xxxxx/public_html/wp-content/plugins/civicrm/civicrm/bin/cli.class.php on line 91

When submitting the link directly in the browser, it works well.

PHP 5.4.43 CiviCRM 4.6.7 Wordpress 4.4.1

4
  • 1
    I also get the message 'ERROR: You need to send a valid user name and password to execute this file' but intermittently so I think it's a bug, and not going to help you with debugging your problems. That message comes from the Civi code in System.php. For what it's worth, here's my cron statement which does work: wget -O - -q -t 1 "example.co.uk/sites/all/modules/civicrm/bin/…"
    – Andy Clark
    Feb 2, 2016 at 17:36
  • 1
    Try submitting the link directly in a browser to see if it works, or takes an error. You may learn more about the problem.
    – DaveD
    Feb 2, 2016 at 21:32
  • 1
    I have reported the spurious message (discussed above) - it's issues.civicrm.org/jira/browse/CRM-17954 I get these messages once/twice day with cron running perfectly!
    – Andy Clark
    Feb 3, 2016 at 8:43
  • I had similar problems. See civicrm.stackexchange.com/questions/11027/…
    – P a u l
    Apr 10, 2017 at 20:50

2 Answers 2

3

You may want to try creating a wgetrc file that contains all your values. Check the man page for wget as a reference.. Here's a wgetrc of mine:

post-data=name=civicron&pass=<password>&key=<sitekey>
output_document = -
quiet=on
timeout=1

Also - check your Apache/nginx logs for the actual URL that was requested that corresponds to a wget that resulted in a "You need to send a valid key" error. Maybe something is getting truncated; the web server log can help determine this.

3

Thanks for helping. Looking at the log showed that everything after & was getting truncated.

There should be "backslash" () sign before "and" (&) sign.

/usr/bin/wget -O - -q -t 1 http://www.site.org/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=XXXX\&pass=XXXX\&key=XXXXX

Your Answer

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

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