Answers.Body: <p>You may want to try creating a wgetrc file that contains all your values.  Check the <a href="https://www.gnu.org/software/wget/manual/wget.html" rel="nofollow">man page</a> for wget as a reference.. Here's a wgetrc of mine:</p>
  
  <pre><code>post-data=name=civicron&amp;pass=&lt;password&gt;&amp;key=&lt;sitekey&gt;
  output_document = -
  quiet=on
  timeout=1
  </code></pre>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-13T21:08:30.867Z
Answers.LastActivityDate: 2016-02-13T21:08:30.867Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>Thanks for helping. Looking at the log showed that everything after &amp; was getting truncated.</p>
  
  <p>There should be "backslash" () sign before "and" (&amp;) sign.</p>
  
  <blockquote>
    <p>/usr/bin/wget -O - -q -t 1
    <a href="http://www.site.org/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=XXXX" rel="nofollow">http://www.site.org/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=XXXX</a>\&amp;pass=XXXX\&amp;key=XXXXX</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-15T20:40:17.067Z
Answers.LastActivityDate: 2016-02-15T20:40:17.067Z
Answers.UserDisplayName: Francis Poisson
Body: <p>I've tried different ways to setup cron jobs.</p>
  
  <p>When using that cron job, the file is not able to read the parameters (like key, etc.)</p>
  
  <blockquote>
    <p>/usr/bin/wget -O - -q -t 1 <a href="http://www.site.org/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=XXXX&amp;pass=XXXX&amp;key=XXXXX" rel="nofollow">http://www.site.org/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=XXXX&amp;pass=XXXX&amp;key=XXXXX</a></p>
  </blockquote>
  
  <p>The e-mail I received says: ERROR: You need to send a valid key to execute this file.</p>
  
  <p>When using those cron jobs, they are not running:</p>
  
  <blockquote>
    <p>/usr/bin/wget -O - -q -t 1 '<a href="http://www.xxxx.org/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=XXXX&amp;pass=XXXX&amp;key=XXXXX" rel="nofollow">http://www.xxxx.org/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=XXXX&amp;pass=XXXX&amp;key=XXXXX</a>'</p>
    
    <p>/usr/bin/wget -O - -q -t 1 "<a href="http://www.xxxxx.org/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=XXXX&amp;pass=XXXX&amp;key=XXXXX" rel="nofollow">http://www.xxxxx.org/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=XXXX&amp;pass=XXXX&amp;key=XXXXX</a>"</p>
  </blockquote>
  
  <p>When working with php-cli:</p>
  
  <blockquote>
    <p>php /home2/xxx/public_html/wp-content/plugins/civicrm/civicrm/bin/cli.php -s xxxxx.org -u XXXX -p XXXXX -e Job -a execute</p>
  </blockquote>
  
  <p>The PHP error log says:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>When submitting the link directly in the browser, it works well.</p>
  
  <p><strong>PHP 5.4.43
  CiviCRM 4.6.7
  Wordpress 4.4.1</strong></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-02T17:36:46.933Z
Comments.Text: 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 "https://www.example.co.uk/sites/all/modules/civicrm/bin/cron.php?name=CronAd&pass=xxxxxx&key=xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Comments.UserDisplayName: Andy Clark
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-02T21:32:51.000Z
Comments.Text: Try submitting the link directly in a browser to see if it works, or takes an error.  You may learn more about the problem.
Comments.UserDisplayName: DaveD
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-03T08:43:29.780Z
Comments.Text: I have reported the spurious message (discussed above) - it's https://issues.civicrm.org/jira/browse/CRM-17954  I get these messages once/twice day with cron running perfectly!
Comments.UserDisplayName: Andy Clark
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-10T20:50:00.540Z
Comments.Text: I had similar problems. See http://civicrm.stackexchange.com/questions/11027/does-anyone-have-a-working-example-for-civimail-bulk-emails-on-wordpress-and-4-7/11059#11059
Comments.UserDisplayName: P a u l
Tags: <cron-job><cron>
Title: Cron job with shared hosting CPanel
ThreadText: # Cron job with shared hosting CPanel
  
  (Asked by: username_0 on 2016-01-26)
  
  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**
  
  **Tags:** cron-job, cron
  
  > **Comments:**
  > **username_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 "https://www.example.co.uk/sites/all/modules/civicrm/bin/cron.php?name=CronAd&pass=xxxxxx&key=xxxxxxxxxxxxxxxxxxxxxxxxxxxx"  
  > **username_2**: Try submitting the link directly in a browser to see if it works, or takes an error.  You may learn more about the problem.  
  > **username_1**: I have reported the spurious message (discussed above) - it's https://issues.civicrm.org/jira/browse/CRM-17954  I get these messages once/twice day with cron running perfectly!  
  > **username_3**: I had similar problems. See http://civicrm.stackexchange.com/questions/11027/does-anyone-have-a-working-example-for-civimail-bulk-emails-on-wordpress-and-4-7/11059#11059  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2016-02-15. Score: 3 | Accepted answer
  
  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
  
  
  ---
  
  ### Answer by username_4 on 2016-02-13. Score: 3
  
  You may want to try creating a wgetrc file that contains all your values. Check the [man page](https://www.gnu.org/software/wget/manual/wget.html) 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.
  
  
  ---
  
  