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 »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Cron Job set up and (hopefully) basic tutorial
Pages: [1]

Author Topic: Cron Job set up and (hopefully) basic tutorial  (Read 2973 times)

jgowans

  • I post occasionally
  • **
  • Posts: 61
  • Karma: 3
    • CiviCRM
Cron Job set up and (hopefully) basic tutorial
November 06, 2013, 07:03:48 am
Hey everyone... I've noticed a lot of posts regarding cron jobs and, as a novice, find myself struggling to determine the proper way to set up a cron job in cPanel.  I've successfully done this with other components, however I'm still failing with civiCRM.  My objective is simply to send reports, i.e. execute all jobs that are enabled.  If I follow the instructions here http://wiki.civicrm.org/confluence/display/CRMDOC/Managing+Scheduled+Jobs, I believe I should end up using the script example
Code: [Select]
$ php /path/to/civicrm/bin/cli.php -s site -u user -p password -e Job -a execute where:
  • $ php is = /path/to/php
  • -s site is = site name
  • -u user is = joomla user with sufficient permissions to run jobs
  • -p password is = joomla user's password
Following this, I end up with
Code: [Select]
/usr/bin/php /home/[directory]/public_html/administrator/components/com_civicrm/civicrm/bin/cli.php [sitename] [username] [password] -e Job -a execute  This, however, generates a 500 internal server error.  Sooo, I'm wondering if anyone could assist in determining where I'm going wrong in this cron job.  Again, using cPanel with other crons working properly.  Thanks for your help!
CiviCRM Core Team

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 Job set up and (hopefully) basic tutorial
November 06, 2013, 07:47:38 am

can you check your apache error logs and get more details on the 500 internal server error. seems like php is either running out of time or memory and hence the internal error

i would try one of the smaller cron jobs in civicrm and ensure they work before executing all of them at once

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

jgowans

  • I post occasionally
  • **
  • Posts: 61
  • Karma: 3
    • CiviCRM
Re: Cron Job set up and (hopefully) basic tutorial
November 06, 2013, 08:43:15 am
I added a second cron specific to the mail report job with the sample script of
Code: [Select]
$ php bin/cli.php -s site -u user -p password -e Job -a <api action> --<params>
Changed it to:
Code: [Select]
/usr/bin/php bin/cli.php -s [Site name] -u [Username] -p [Password] -e Job -a mail_report which resulted in a 404 file not found error

Then changed it to:
Code: [Select]
/usr/bin/php /home/[directory]/public_html/administrator/components/com_civicrm/civicrm/bin/cli.php -s [Site name] -u [Username] -p [Password] -e Job -a mail_report which resulted in a 500 internal server error

Went and downloaded the raw error logs and the only thing is says related to this (searched for "cli.php" and "500") is
Code: [Select]
[06/Nov/2013:09:57:32 -0600] "GET /administrator/components/com_civicrm/civicrm/bin/cli.php HTTP/1.1" 500 - "-"
CiviCRM Core Team

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Cron Job set up and (hopefully) basic tutorial
November 06, 2013, 08:54:07 am
I'm not sure I understand the error message. if you use php bin/cli.php syntax, it will NOT go through the webserver (and it's a big benefit of this method).

However, error 404 or 500 are http errors, ie there is still webserver talking somewhere.

If you run php cli, you might get error messages, but it's directly on the shell, no 404 involved ;)
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

jgowans

  • I post occasionally
  • **
  • Posts: 61
  • Karma: 3
    • CiviCRM
Re: Cron Job set up and (hopefully) basic tutorial
November 06, 2013, 09:26:34 am
Changed it back to the original syntax (bin/cli.php) and when the cron executes, I receive a notice with the following:
Quote
Status: 404 Not Found
X-Powered-By: PHP/5.3.20
Content-type: text/html

No input file specified.
CiviCRM Core Team

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 Job set up and (hopefully) basic tutorial
November 06, 2013, 12:17:55 pm

can you cut-n-paste your cron command here. seems like the above is more for a web request, while cli.php is meant to bypass the whole web route :)

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

jgowans

  • I post occasionally
  • **
  • Posts: 61
  • Karma: 3
    • CiviCRM
Re: Cron Job set up and (hopefully) basic tutorial
November 07, 2013, 07:42:28 am
The exact command for the specific job is:
Code: [Select]
/usr/bin/php bin/cli.php -s [Site name] -u [Username] -p [Password] -e Job -a mail_report
For the original cron that I was attempting, it's:
Code: [Select]
/usr/bin/php /home/[directory]/public_html/administrator/components/com_civicrm/civicrm/bin/cli.php -s [sitename] -u [username] -p [password] -e Job -a execute
CiviCRM Core Team

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 Job set up and (hopefully) basic tutorial
November 07, 2013, 09:26:25 am

sorry, i dont know whats happening on your machine

i dont think you are executing php in cli mode (the x-powered-by etc should not appear). i would contact your host and see if they can help out

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

jgowans

  • I post occasionally
  • **
  • Posts: 61
  • Karma: 3
    • CiviCRM
Re: Cron Job set up and (hopefully) basic tutorial
November 07, 2013, 10:51:48 am
Ok, got in touch with my host (Host Gator), which always provides great support.  In this case, however, they pointed me to http://support.hostgator.com/articles/cpanel/what-do-i-put-for-the-cron-job-command and, when I asked which of these options would work for me, they said
Quote
Unfortunately this is pretty out of my scope of support as it involves coding, you may need to contact a developer for this. Wish I could be more help.
 
Soooo, any idea which of these options would work?
CiviCRM Core Team

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Cron Job set up and (hopefully) basic tutorial
November 08, 2013, 10:58:05 am
It has nothing to do with coding ;) you're supposed to run a php from the shell, but the error you mention looks like you're talking to a webserver.

I don't know what's going on on your machine, but it's not doing what it's supposed to
« Last Edit: November 08, 2013, 12:08:58 pm by petednz »
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Ann

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal
  • MySQL version: 5.6
  • PHP version: 5.5
Re: Cron Job set up and (hopefully) basic tutorial
November 26, 2013, 08:10:51 am
You may use a third party cron job service like http://www.easycron.com

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Cron Job set up and (hopefully) basic tutorial

This forum was archived on 2017-11-26.