1

I have the command in cron cd /home/quabbinm/ && /usr/local/bin/drush -r /home/quabbinm/public_html/trainingactivebystanders.org -l https://trainingactivebystanders.org -u nan civicrm-api job.execute which results in errors

X-Powered-By: PHP/5.6.33
Content-type: text/html; charset=UTF-8

<br />
<b>Notice</b>:  Undefined variable: argv in <b>phar:///usr/local/bin/drush/drush</b> on line <b>114</b><br />
<br />
<b>Warning</b>:  array_shift() expects parameter 1 to be array, null given in <b>phar:///usr/local/bin/drush/includes/startup.inc</b> on line <b>171</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>phar:///usr/local/bin/drush/includes/startup.inc</b> on line <b>182</b><br />
<br />
<b>Warning</b>:  pcntl_exec() expects parameter 2 to be array, null given in <b>phar:///usr/local/bin/drush/includes/startup.inc</b> on line <b>359</b><br />
<br />
<b>Notice</b>:  Use of undefined constant STDERR - assumed 'STDERR' in <b>phar:///usr/local/bin/drush/includes/startup.inc</b> on line <b>363</b><br />
<br />
<b>Warning</b>:  fwrite() expects parameter 1 to be resource, string given in <b>phar:///usr/local/bin/drush/includes/startup.inc</b> on line <b>363</b><br />
<br />
<b>Notice</b>:  Use of undefined constant STDERR - assumed 'STDERR' in <b>phar:///usr/local/bin/drush/includes/startup.inc</b> on line <b>364</b><br />
<br />
<b>Warning</b>:  fwrite() expects parameter 1 to be resource, string given in <b>phar:///usr/local/bin/drush/includes/startup.inc</b> on line <b>364</b><br />

When I run the same command at the command line it runs fine

3
  • two questions: if you run drush manually on the command line do you get the same errors? can you try to have your cron task cd into the site directory so you can run drush without having to give it the site parameters ?
    – ericG
    Jan 28 '18 at 0:49
  • When I run this at the command line it runs fine. I am doing a cd into the site directory. What are you suggesting otherwise? Jan 29 '18 at 14:50
  • I tried this cd /home/quabbinm/public_html/trainingactivebystanders.org && /usr/local/bin/drush -r trainingactivebystanders.org -u nan civicrm-api job.execute and get the message civicrm-api job.execute can't be found Jan 29 '18 at 15:40
1

It looks like you are using an incorrect version of php when this command runs from cron. According to this resource you are receiving these errors because you are using php-cgi rather than the php CLI binary. Most reports of this error are regarding 1 & 1 hosting.

Rather than using /usr/bin/drush use something like this:

/usr/bin/php /usr/local/bin/drush {rest of the command}

Where /usr/bin/php is the path to the php CLI binary on your system.

-1

Add this line to the crontab file:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
1
  • 2
    Thanks for contributing. It helps if you explain why you are recommending something and how it helps solve the issue. Since the command in cron is using absolute paths, it is not obvious why setting the path variable will make any difference.
    – Aidan
    Jul 13 '18 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.