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) »
  • Launching cron jobs - failed to open stream: No such file or directory
Pages: [1]

Author Topic: Launching cron jobs - failed to open stream: No such file or directory  (Read 2989 times)

PaulVanLil

  • I’m new here
  • *
  • Posts: 26
  • Karma: 0
    • VanLil.be
  • CiviCRM version: civicrm 4.0.6
  • CMS version: Joomla 1.6
  • MySQL version: 5.1.52
  • PHP version: 5.3.3
Launching cron jobs - failed to open stream: No such file or directory
March 01, 2011, 05:12:13 am
I am working in joomla and I am trying to launch cron jobs, with no result so far.

The steps I took:

1. create the civicrm-wgetrc
Using my php-editor, I created .civicrm-wgetrc with content "post-data=name=username&pass=password&key=site-key"

I stored .civicrm-wgetrc in the root directory.

2. set up the cron job with the following command
Code: [Select]
cd /***/***/***/joomla/administrator/components/com_civicrm/civicrm; wget -O - -q -t 1  export WGETRC=civicrm-wgetrc  http://***/joomla/administrator/components/com_civicrm/civicrm/bin/civimail.cronjob.php

The result I received in my e-mail is the following:
Code: [Select]
<br />
<b>Warning</b>:  require_once(bin/cli.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in <b>/***/***/***/joomla/administrator/components/com_civicrm/civicrm/bin/civimail.cronjob.php</b> on line <b>71</b><br />
<br />
<b>Fatal error</b>:  require_once() [<a href='function.require'>function.require</a>]: Failed opening required 'bin/cli.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in <b>/***/***/***/joomla/administrator/components/com_civicrm/civicrm/bin/civimail.cronjob.php</b> on line <b>71</b><br />

So, the prog does not find cli.php.
Nevertheless, I changed the root-directory to have the cron job start in the root where civicrm is installed.

Any idea?

Thanks,
Paul

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Launching cron jobs - failed to open stream: No such file or directory
March 01, 2011, 06:05:25 am
Hi,

if you are using wget, it doesn't matter from where you call it, that's when you call it using php-cli

The script is supposed to work in both cases, and detect automatically if it's called as a webpage (via wget) or as a script.

In your webserver configuration, it seems that it's wrongly thinking it's called as a script.

btw, easier for testing to call it directly from your browser and see the result.

http://***/joomla/administrator/components/com_civicrm/civicrm/bin/civimail.cronjob.php?name=username&pass=password&key=site-key


Can you try to replace the line
Code: [Select]
// you can run this program either from an apache command, or from the cli
if (isset($argv)) {
by the line

Code: [Select]
if ( php_sapi_name() == "cli" ) {

argv isn't supposed to be set while running from the website, but in your case seems the case.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

PaulVanLil

  • I’m new here
  • *
  • Posts: 26
  • Karma: 0
    • VanLil.be
  • CiviCRM version: civicrm 4.0.6
  • CMS version: Joomla 1.6
  • MySQL version: 5.1.52
  • PHP version: 5.3.3
Re: Launching cron jobs - failed to open stream: No such file or directory
March 01, 2011, 09:19:23 am
Thanks Xavier,

civimail.cronjob.php runs now. I received the groupmail.

By the way, I do not have access to the command line, but found a script which executes command lines:

Code: [Select]
<form name="signupform" method="post" action="run.php">
<table align="left" valign="top" width="100%" border="0"><tbody>
<tr>
<td><font class="label2">Command:</font></td>
<td>
<input class="formtext2" type="text" name="command" size="100">
<input class="formbuton" type="submit" value="OK">
</td>
</tr>
</tbody></table>
</form>

<?
function cmd_exec($cmd, &$stdout, &$stderr)
{
   $outfile = tempnam(".", "cmd");
   $errfile = tempnam(".", "cmd");
   $descriptorspec = array(
       0 => array("pipe", "r"),
       1 => array("file", $outfile, "w"),
       2 => array("file", $errfile, "w")
   );
   $proc = proc_open($cmd, $descriptorspec, $pipes);

   if (!is_resource($proc)) return 255;

   fclose($pipes[0]);    //Don't really want to give any input

   $exit = proc_close($proc);
   $stdout = file($outfile);
   $stderr = file($errfile);

   unlink($outfile);
   unlink($errfile);
   return $exit;
}


if (isset($_POST['command']))
{
echo 'Command: ' . $_POST['command'] . '<br>';
$exit = cmd_exec($_POST['command'],$stdout, $stderr);

    //print the output
foreach ($stdout as $line)
{
echo "$line<br>";
}

    //in case there an error is returned
foreach ($stderr as $line)
{
echo "$line<br>";
}
}
?>

Save this script as run.php in a directory with the approriate chmod.
Next run the http://your/url/to/run.php
In the command line, fill in: php -v

Doing this, my server responds:
Code: [Select]
PHP 5.2.16 (cli) (built: Jan 20 2011 21:39:05)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

The "cli" on the first line explains that php-cli is installed on the server which I am using (which I thought was not the case).

Xavier, I do not know that the fact of running php-cli changes something in the modif we made to civimail.cronjob.php

I'll keep you updated on the rest of the config and running of my cron-jobs.

Thanks,
Paul

PaulVanLil

  • I’m new here
  • *
  • Posts: 26
  • Karma: 0
    • VanLil.be
  • CiviCRM version: civicrm 4.0.6
  • CMS version: Joomla 1.6
  • MySQL version: 5.1.52
  • PHP version: 5.3.3
Re: Launching cron jobs - failed to open stream: No such file or directory
March 01, 2011, 10:31:17 am
I was too fast  :'(

Calling the cron-job from the browser works; but calling it as a cron-job fails.

As explained above, I created a .civicrm-wgetrc with content "post-data=name=username&pass=password&key=site-key".

This time I placed it in the root where I installed joomla.

The following cron-job runs as it should:
Code: [Select]
wget -O - -q -t 1  "http://***/joomla/administrator/components/com_civicrm/civicrm/bin/civimail.cronjob.php?name=***&pass=***&key=***"

The following cron-job gives an error:
Code: [Select]
wget -O - -q -t 1  export WGETRC=civicrm-wgetrc  http://***/joomla/administrator/components/com_civicrm/civicrm/bin/civimail.cronjob.php

The error I receive is: ERROR: You need to send a valid user name and password to execute this file

Apparently, it has something to do with the url packed in " " in the first command and not in the second command.

Nevertheless, I tried the second command with the url packed in " " and giving the full path to civicrm-wgetrc as WGETRC=/***/***/***/joomla/civicrm-wgetrc
It always results in: ERROR: You need to send a valid user name and password to execute this file

Thus, the civicrm-wgetrc is not recognized and no user and password is transferred to the cron-job.
 





Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Launching cron jobs - failed to open stream: No such file or directory
March 01, 2011, 03:28:20 pm
So then use the first one if it works. :)

That's how I do cron jobs BTW.
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.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Launching cron jobs - failed to open stream: No such file or directory
March 01, 2011, 11:03:20 pm
;)

using post for the params avoid having them in clear in the webserver logs.

As you do hosting too. I would suggest you to look at the php-cli version, so you can less penalise the normal users while a mailing is going out (you can run them at a lower prio than the web server).

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • Launching cron jobs - failed to open stream: No such file or directory

This forum was archived on 2017-11-26.