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 »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Issue setting up Scheduled Jobs
Pages: [1]

Author Topic: Issue setting up Scheduled Jobs  (Read 2177 times)

combrains

  • I post occasionally
  • **
  • Posts: 40
  • Karma: 2
  • CiviCRM version: 4.3.3
  • CMS version: Joomla 3.1.x
  • MySQL version: 5.1.44
  • PHP version: 5.3.1
Issue setting up Scheduled Jobs
July 04, 2013, 08:45:57 pm
Hi All,

I have yet another question in relation to scheduled jobs running via the CLI.

I am trying to set up my cron job using the command
Code: [Select]
php /var/www/vhosts/musikmakers.org.nz/subdomains/dev/httpdocs/administrator/components/com_civicrm/civicrm/bin/cli.php -u <username> -p <password> -e Job -a execute
Whenever I try to run the job, PHP spits out this error:
Code: [Select]
Warning: chdir(): SAFE MODE Restriction in effect.  The script whose uid is 10729 is not allowed to access . owned by uid 0 in /var/www/vhosts/musikmakers.org.nz/subdomains/dev/httpdocs/administrator/components/com_civicrm/civicrm/bin/cli.class.php on line 200

Warning: civicrm_cli::require_once(civicrm.config.php): failed to open stream: No such file or directory in /var/www/vhosts/musikmakers.org.nz/subdomains/dev/httpdocs/administrator/components/com_civicrm/civicrm/bin/cli.class.php on line 201

Fatal error: civicrm_cli::require_once(): Failed opening required 'civicrm.config.php' (include_path='.:/usr/share/php') in /var/www/vhosts/musikmakers.org.nz/subdomains/dev/httpdocs/administrator/components/com_civicrm/civicrm/bin/cli.class.php on line 201

I have spoken with my host and they have assured me that PHP safe mode is disabled.  From these error messages, I'm guessing that one of two things are happening: either the script is not cd'ing into the right directory or, the include path is not being set correctly, resulting in PHP being unable to find civicrm.config.php

Any advice as to what I should be checking in both my Civi/Joomla environment as well as my hosting environment would be greatly appreciated.  The configuration is 90% there, I just need to clear this hurdle before deploying Civi into our live site.

Joomla 3.x with CiviCRM 4.3.4.

Cheers

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Issue setting up Scheduled Jobs
July 05, 2013, 04:45:10 am
You see that PHP itself says on your server:

Code: [Select]
SAFE MODE Restriction in effect
and still your host says:

Quote
PHP safe mode is disabled

It seems clear that this is a contradiction, or they have their server configured in a very unusual way. Your host has no suggestion how to make this work? They should certainly know how to on their servers.
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.

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: Issue setting up Scheduled Jobs
July 05, 2013, 11:09:41 am
Since there seems to be some doubt about safe mode, you can create a file called "info.php" on your server with these contents:

<?php

phpinfo();

?>


Bring up that page in your web browser, and look at the setting for safe_mode.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

combrains

  • I post occasionally
  • **
  • Posts: 40
  • Karma: 2
  • CiviCRM version: 4.3.3
  • CMS version: Joomla 3.1.x
  • MySQL version: 5.1.44
  • PHP version: 5.3.1
Re: Issue setting up Scheduled Jobs
July 07, 2013, 06:17:43 pm
Thanks for your replies so far.

As suggested by JonGold,  I ran a phpinfo() on the domain - safe_mode reports to be off as per the attached screenshot.  Any suggestions as to where from here?

Cheers

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: Issue setting up Scheduled Jobs
July 08, 2013, 08:22:37 am
I just re-read this, and realized that what I suggested would be testing your Apache's php.ini, not the command line's php.ini.  Which could also explain why your ISP thinks safe mode is off - for the vast majority of folks, it is.

So you can do this:
run "php --ini".  That will tell you where the php.ini file that's being used is.  For instance - on my server it's at /etc/php5/cli/php.ini.  Look in THAT file for "safe_mode", and you can go back to your ISP and ask them to disable safe mode for CLI PHP, not just Apache-based PHP.

You may also be able to add "-d safe_mode=Off", depending on your ISP's settings, like so:
php -d safe_mode=Off /var/www/vhosts/musikmakers.org.nz/subdomains/dev/httpdocs/administrator/components/com_civicrm/civicrm/bin/cli.php -u <username> -p <password> -e Job -a execute
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

combrains

  • I post occasionally
  • **
  • Posts: 40
  • Karma: 2
  • CiviCRM version: 4.3.3
  • CMS version: Joomla 3.1.x
  • MySQL version: 5.1.44
  • PHP version: 5.3.1
Re: Issue setting up Scheduled Jobs
July 08, 2013, 02:03:11 pm
Ah-ha!  Thanks Jon,  I did not realise that there were two distinct php.ini files.  I will go back and ask them.

Quote from: JonGold on July 08, 2013, 08:22:37 am
You may also be able to add "-d safe_mode=Off", depending on your ISP's settings, like so:
php -d safe_mode=Off

What will the -d switch do?  Will it force safe mode off if it is set in the ini file?

Cheers

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: Issue setting up Scheduled Jobs
July 08, 2013, 02:06:14 pm
That's correct!
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

combrains

  • I post occasionally
  • **
  • Posts: 40
  • Karma: 2
  • CiviCRM version: 4.3.3
  • CMS version: Joomla 3.1.x
  • MySQL version: 5.1.44
  • PHP version: 5.3.1
Re: Issue setting up Scheduled Jobs
July 08, 2013, 02:18:27 pm
Woot!  One issue solved.  adding the -d safe_mode=Off to the cron job solved the issue of safe mode.

However, the job still fails with the error:
Code: [Select]
Warning: civicrm_cli::require_once(civicrm.config.php): failed to open stream: No such file or directory in /var/www/vhosts/musikmakers.org.nz/subdomains/dev/httpdocs/administrator/components/com_civicrm/civicrm/bin/cli.class.php on line 201

Fatal error: civicrm_cli::require_once(): Failed opening required 'civicrm.config.php' (include_path='.:/usr/share/php') in /var/www/vhosts/musikmakers.org.nz/subdomains/dev/httpdocs/administrator/components/com_civicrm/civicrm/bin/cli.class.php on line 201

This suggests to me that the path for the civicrm.config.php file is not being found. correct?  Is this another PHP config issue?

Cheers

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: Issue setting up Scheduled Jobs
July 08, 2013, 02:38:19 pm
It sounds like a possible permissions problem.  Check that file path, ensure the file exists; check the permissions, and check the user you're running the cron job as.  I usually make my "www-data" user the one that runs Civi cron jobs, since it will have the same permissions as Apache on my server - otherwise I a) need to make sure a separate user has all the necessary permissions, and b) if my cron job creates any files (it often creates templates_c files), they may end up creating files that the www-data user doesn't have access to.

Of course, if you're not on a Debian server, your Apache user probably isn't www-data!
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

combrains

  • I post occasionally
  • **
  • Posts: 40
  • Karma: 2
  • CiviCRM version: 4.3.3
  • CMS version: Joomla 3.1.x
  • MySQL version: 5.1.44
  • PHP version: 5.3.1
Re: Issue setting up Scheduled Jobs
July 08, 2013, 02:47:00 pm
OK.  Will look into this with my host.  The annoying thing is that I don't have CLI access  >:(

Will report back with success or failure.

Thanks for the help to date - much appreciated.

combrains

  • I post occasionally
  • **
  • Posts: 40
  • Karma: 2
  • CiviCRM version: 4.3.3
  • CMS version: Joomla 3.1.x
  • MySQL version: 5.1.44
  • PHP version: 5.3.1
Re: Issue setting up Scheduled Jobs
July 08, 2013, 06:39:20 pm
OK, so after having my host look into the issue surrounding the php.ini file, they have modified the cron command to read thus:
Code: [Select]
php -f /etc/webhost-php53-cgi/cgi-default /var/www/vhosts/musikmakers.org.nz/subdomains/dev/httpdocs/administrator/components/com_civicrm/civicrm/bin/cli.php -u <username> -p <password> -e Job -a execute

Apparently this calls the same PHP.ini as used by apache in our vhost on the server, rather than the system default file which has safe mode enabled.  So far I have not received any emails from the cron daemon reporting errors.  However, although I have some scheduled jobs set to run 'always', they do not appear to fire as there are no log entries for them.

Are there any other system logs I can check or get my host to check in order to see what the cron job is doing?

Cheers

combrains

  • I post occasionally
  • **
  • Posts: 40
  • Karma: 2
  • CiviCRM version: 4.3.3
  • CMS version: Joomla 3.1.x
  • MySQL version: 5.1.44
  • PHP version: 5.3.1
Re: Issue setting up Scheduled Jobs
July 10, 2013, 05:51:12 pm
Bump!  Any Advice?

Obviously errors aren't going to show in my http error or access logs.

Thanks for all the help so far.

Cheers

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Issue setting up Scheduled Jobs
July 11, 2013, 03:17:55 am
The Scheduled Jobs page shows when each was last run. What do you see there?
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.

combrains

  • I post occasionally
  • **
  • Posts: 40
  • Karma: 2
  • CiviCRM version: 4.3.3
  • CMS version: Joomla 3.1.x
  • MySQL version: 5.1.44
  • PHP version: 5.3.1
Re: Issue setting up Scheduled Jobs
July 11, 2013, 02:16:02 pm
If I check the scheduled jobs log in Civi, the date shown is the date that I last fired them manually via the admin console.  This is why I suspect that they are not firing via the cron cli.  Either that or they are not being logged in Civi.

Cheers

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Issue setting up Scheduled Jobs
July 14, 2013, 10:32:31 am
Not sure. I think you should check the output of the PHP CLI command.
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 »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Issue setting up Scheduled Jobs

This forum was archived on 2017-11-26.