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 »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • CiviMail cronjob on a multi site with civicrm outside of the /var/www folder
Pages: [1]

Author Topic: CiviMail cronjob on a multi site with civicrm outside of the /var/www folder  (Read 2224 times)

desert_rider

  • Guest
CiviMail cronjob on a multi site with civicrm outside of the /var/www folder
June 03, 2009, 09:41:47 am
Hi,

I've set up the CiviMail cron without any trouble before but at the moment I'm doing a civicrm install where drupal and civicrm codebases are outside of the html folder and symlinked in. The CiviMail cronjob won't seem to work...

It is a multi-site setup. The folder structure is as below:

CODEBASE FOLDER: /var/home/
the codebase folder contains:
 - /var/home/drupal-code                                              (drupal code)
 - /var/home/drupal-code/sites/all/modules/civicrm            (civicrm code)

WEB-ACCESSIBLE FOLDER: /var/www/
the web-accessible folder contains:
 - /var/www/index.php  (where index.php just has an "include('/var/home/index.php')" )
 - /var/www/cron.php   (where cron.php just has an "include('/var/home/cron.php')" )
etc - the rest of the files required in the root go on like this

the civicrm codebase is symlinked in with: /var/www/second-drupal-site/sites/all --> /var/home/drupal-code/sites/all/


All the Drupal and CiviCRM multisite installs are working as they should.

However, the last thing I'm doing is setting up the crons! It is always the last thing that gets you huh?

So, I think my link to set off the civimail.cronjob.php should be:
http://www.example.org/second-drupal-site/sites/all/modules/civicrm/bin/civimail.cronjob.php?name=<user>&pass=<pass>&key=<key>

If i load the above URL in my browser it doesn't initiate the scheduled mailings, no errors returned, just a white page. However, if I go to the /civicrm/mailing/queue?reset=1 URL manually when logged in it works fine.

This is the error that the cronjob returns in Webmin (i have it pointed to a file called civimailcron.php in the /var/www/ folder which includes the above civimail.cronjob.php URL):

/var/www/civimailcron.php: line 1: ?php: No such file or directory
/var/www/civimailcron.php: line 2: syntax error near unexpected token `'http://www.example.org/second-drupal-site/sites/all/modules/civicrm/bin/civimail.cronjob.php?name=<user>&pass=<pass>&key=<key>''
/var/www/civimailcron.php: line 2: `include('http://www.example.org/second-drupal-site/sites/all/modules/civicrm/bin/civimail.cronjob.php?name=<user>&pass=<pass>&key=<key>');'

the contents of the civimailcron.php file:
Code: [Select]
<?php
include('http://www.example.org/second-drupal-site/sites/all/modules/civicrm/bin/civimail.cronjob.php?name=<user>&pass=<pass>&key=<key>');
?>

Any ideas?

Apologies for the long post but this isn't a vanilla install! I thought I better get all the details out there.

Thanks for your help!

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: CiviMail cronjob on a multi site with civicrm outside of the /var/www folder
June 03, 2009, 11:53:22 am

there is an error with: /var/www/civimailcron.php

ensure it starts with <?php

Also ensure you are calling it with php, i.e. "php /var/www/civimailcron.php" see the syntax error that is spit 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

desert_rider

  • Guest
Re: CiviMail cronjob on a multi site with civicrm outside of the /var/www folder
June 03, 2009, 06:36:44 pm
Thanks lobo -

I've set the cron command to: "php /var/www/civimailcron.php > /dev/null"

It now returns the error: "PHP Warning:  include(): URL file-access is disabled in the server configuration in /var/www/civimailcron.php on line 2". PHP won't include the 'external' URL which is a good thing...

for reference civimailcron.php contains:
Code: [Select]
<?php
include('http://www.example.org/second-drupal-site/sites/all/modules/civicrm/bin/civimail.cronjob.php?name=<user>&pass=<pass>&key=<key>');
?>


so if I edit civimailcron.php and make it:
Code: [Select]
<?php
include('/var/www/second-drupal-site/sites/all/modules/civicrm/bin/civimail.cronjob.php?name=<user>&pass=<pass>&key=<key>');
?>

the cron returns failed to open stream: No such file or directory in /var/www/civimailcron.php on line 2 It guess it can't follow the /var/www/second-drupal-site/sites/all --> /var/home/drupal-code/sites/all/ symlink

Pasting the URL http://www.example.org/second-drupal-site/sites/all/modules/civicrm/bin/civimail.cronjob.php?name=<user>&pass=<pass>&key=<key> into a browser finds the script, but it doesn't execute the cron.

Is there a third way of getting the cron to find the civimail.cronjob.php file?

Thanks!

There is a cheap way of overcoming this and it is to make a drupal block that redirects the user from /civicrm/mailing?reset=1 to /civicrm/mailing/queue?reset=1 but that would only work if they are sending the email immediately. Any time delay, and they would have to come back in the future to set off the queue, which kind of defeats the purpose of a time delay....
« Last Edit: June 03, 2009, 06:43:14 pm by desert_rider »

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: CiviMail cronjob on a multi site with civicrm outside of the /var/www folder
June 04, 2009, 06:32:22 am

you will need to work with your local sysadmin and figure out how to invoke that script directly from cron. Any reason why you cannot use:

php http://www.example.org/second-drupal-site/sites/all/modules/civicrm/bin/civimail.cronjob.php?name=<user>&pass=<pass>&key=<key>

directly into cron? You might need to escape the &

finally you can try to do it via a .sh file and trigger cron from it

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

desert_rider

  • Guest
Re: CiviMail cronjob on a multi site with civicrm outside of the /var/www folder
June 04, 2009, 08:18:15 am
Thanks lobo - I appreciate your assistance!

Is it possible that through the multi-site config it isn't picking up the correct database on which to process the queue? I thought it probably should know which site I'm trying to process because the url /second-drupal-site/ is in the url that I'm calling but I thought it worth asking.

Because of the symptoms, I'm beginning to think that maybe multi-site confusion is the reason... the civicrm codebase is in the /drupal/sites/all/modules folder though so maybe not.

I tried the exact url for the cron as you suggested but cron says it can't find the file (Could not open input file: http://...) however, if I load the url in my browser apache can find it (a simple print 'hello'; proved that). However, in neither case does the civimail queue initiate... the only way I can get it to go is via the /civicrm/mailing/queue?reset=1 url.

Oh, and I am the sysadmin :) this is an AWS EC2 instance...

Lastly, the name, pass and key are only letters and numbers so nothing nasty that could be throwing it off

I'll leave it for now. I'm going to setup the Membership status update next which based on this I fear may fail as well.... but we'll see! I might end up making a custom script if I can't get them working.

Thanks for your interest lobo
« Last Edit: June 04, 2009, 08:22:19 am by desert_rider »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • CiviMail cronjob on a multi site with civicrm outside of the /var/www folder

This forum was archived on 2017-11-26.