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 »
  • Installing CiviCRM »
  • CiviMail installation and configuration (Moderator: Donald Lobo) »
  • simple (ish) file to call to activate civimail.cronjob and EmailProcessor
Pages: [1]

Author Topic: simple (ish) file to call to activate civimail.cronjob and EmailProcessor  (Read 1032 times)

Erich Schulz

  • I post frequently
  • ***
  • Posts: 142
  • Karma: 5
    • When no-one understands what you are going on about its time to start a blog
  • CiviCRM version: 4.4
  • CMS version: Drupal 7
  • MySQL version: 5.somthing
  • PHP version: 5.3.3
simple (ish) file to call to activate civimail.cronjob and EmailProcessor
April 10, 2011, 12:12:17 am
ok, maybe just due to the idiosyncrantic configuration of my host I've had a hell of a time getting these two jobs packaged up into a cron job I could call from php-cli (my host wont let me at wget for some reason)

anyway I did my best to make a tidyish package to fire both scripts... and along the way report on some of the issues that were causing grief (I left my debugging echos as comments as no doubt other people with other configuration and version would encounter their own set of hurdles)

hopefully this script maybe of use to somebody... but its a bit rough

I think (???) its better to have the password in a php file than be imbedding paremeters in the open so this maybe a minor step forward for the other people with retarded servers...

the one obvious improvement would be to store (? in a text file) a time stamp of when the process ran last... that way this time could be reported if the script was called too frequently it would just abort. So that would stop the script from being usable in a "denial of service" attack.

I was kinda trying to get anything to work... and as the script evolved I thought it would be optimal if it could be called (and work) using:
  • php cli
  • wget
  • and http...


Well one out of three isn't bad... is it? I don't have wget (as above) so can't test that, and the EmailProcessor bit is also still failing if I call it from firefox with http

A http call gives:

"Failed opening required '../civicrm.config.php' (include_path='.:/hsphere/local/home/antarqld/antarqld.org.au/sites/all/modules/civicrm:/hsphere/local/home/antarqld/antarqld.org.au/sites/all/modules/civicrm/packages:packages/:/hsphere/local/home/antarqld/antarqld.org.au/sites/all/modules/civicrm/:/hsphere/local/home/antarqld/antarqld.org.au/sites/all/modules/civicrm/bin/:.:/hsphere/shared/apache/libexec/php5ext/php/') in /hsphere/local/home/antarqld/antarqld.org.au/sites/all/modules/civicrm/bin/EmailProcessor.php on line 291"

and I can't figure that out...

but anyway the cli part appears be working assuming CiviMailCron is silent on success! Is it?

I'll report further as I test it more, but any comments welcome



<?php
/**
 * @file
 * Handles incoming requests to fire off regularly-scheduled tasks (cron jobs).
 * example cron job for cli:
 * /hsphere/shared/php5/bin/php-cli /hsphere/local/home/antarqld/antarqld.org.au/ErichsCron.php
 */
$name='DRUPAL ACCOUNT NAME HERE';
$pass='YOUR PASSWORD';
//$key='YOUR KEY HERE'; // actually didn't end up needing this

$bpath='/hsphere/local/home/antarqld/antarqld.org.au';


$civicrm_root="$bpath/sites/all/modules/civicrm"; // global variable used referenced by cli.php and ?other places
$include_path = "$civicrm_root/:$civicrm_root/bin/:";
set_include_path($include_path.get_include_path());
session_start();
ini_set('display_errors','On');

?><html><body>
<h1>Running Mail Cron Jobs</h1>
<?php
//var_dump($argv);
if (!$argv[1]) {
echo "<p>Populating argv</p>\n";
if (!$argv) $argv[]="$bpath/ErichsCron.php";
$argv[]="-sdefault";
$argv[]="-u$name";
$argv[]="-p$pass"; }
//var_dump($argv);
//echo '<p>Path='.get_include_path()."</p>\n";

echo "<h2>Running CiviMailCron</h2>\n<p>";
chdir($civicrm_root);
include_once 'bin/civimail.cronjob.php';

echo "</p>\n<h2>Running EmailProcessor:</h2>\n<p>";
include_once 'bin/EmailProcessor.php';
echo "</p>\n";

?>
</body></html>



« Last Edit: April 10, 2011, 04:45:51 am by Erich Schulz »

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: simple (ish) file to call to activate civimail.cronjob and EmailProcessor
April 10, 2011, 02:12:58 am
Quote from: Erich Schulz on April 10, 2011, 12:12:17 am
A http call gives:

"Failed opening required '../civicrm.config.php' (include_path='.:/hsphere/local/home/antarqld/antarqld.org.au/sites/all/modules/civicrm:/hsphere/local/home/antarqld/antarqld.org.au/sites/all/modules/civicrm/packages:packages/:/hsphere/local/home/antarqld/antarqld.org.au/sites/all/modules/civicrm/:/hsphere/local/home/antarqld/antarqld.org.au/sites/all/modules/civicrm/bin/:.:/hsphere/shared/apache/libexec/php5ext/php/') in /hsphere/local/home/antarqld/antarqld.org.au/sites/all/modules/civicrm/bin/EmailProcessor.php on line 291"

and I can't figure that out...

My guess is that the script "thinks" it's being called from CLI that's why. See this line:

Code: [Select]
if ( php_sapi_name() == "cli" ) {
of EmailProcessor.php to check.

Quote from: Erich Schulz on April 10, 2011, 12:12:17 am
but anyway the cli part appears be working assuming CiviMailCron is silent on success! Is it?

Yes.
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.

Erich Schulz

  • I post frequently
  • ***
  • Posts: 142
  • Karma: 5
    • When no-one understands what you are going on about its time to start a blog
  • CiviCRM version: 4.4
  • CMS version: Drupal 7
  • MySQL version: 5.somthing
  • PHP version: 5.3.3
Re: simple (ish) file to call to activate civimail.cronjob and EmailProcessor
April 10, 2011, 04:48:02 am
Thanks Hersel good to know. the big mail out goes out tommorrow, and I'll report the outcome using the above script from php-cli

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • CiviMail installation and configuration (Moderator: Donald Lobo) »
  • simple (ish) file to call to activate civimail.cronjob and EmailProcessor

This forum was archived on 2017-11-26.