2

My Drupal 6 sites are hosted on a Linux server with Apache 2.2, PHP 5.5, MySQL 5.6 installed. I use Drush 8 which I installed via composer. I set a cron job via cPanel which runs every day this script:

#!/bin/bash
# Script to execute all the cron jobs with drush
echo '**************** French site *******************'
cd /home/myuser/public_html/fr/sites/fr.mysite.com
/home/myuser/.composer/vendor/bin/drush -v core-cron
echo '**************** English site ******************'
cd /home/myuser/public_html/en/sites/en.mysite.com
/home/myuser/.composer/vendor/bin/drush -v core-cron
echo '**************** Spanish site ******************'
cd /home/myuser/public_html/es/sites/es.mysite.com
/home/myuser/.composer/vendor/bin/drush -v core-cron
echo '**************** Completed **********************'

But it fails and ends with:

**************** French site *******************
X-Powered-By: PHP/5.5.33
Content-type: text/html

<br />
<b>Warning</b>:  proc_open(): Descriptor item must be either an array or a File-Handle in <b>/home/myuser/.composer/vendor/drush/drush/includes/startup.inc</b> on line <b>434</b><br />
<br />
<b>Warning</b>:  proc_get_status() expects parameter 1 to be resource, boolean given in <b>/home/myuser/.composer/vendor/drush/drush/includes/startup.inc</b> on line <b>435</b><br />
<br />
<b>Warning</b>:  proc_close() expects parameter 1 to be resource, boolean given in <b>/home/myuser/.composer/vendor/drush/drush/includes/startup.inc</b> on line <b>436</b><br />
**************** English site ******************
X-Powered-By: PHP/5.5.33
Content-type: text/html

<br />
<b>Warning</b>:  proc_open(): Descriptor item must be either an array or a File-Handle in <b>/home/myuser/.composer/vendor/drush/drush/includes/startup.inc</b> on line <b>434</b><br />
<br />
<b>Warning</b>:  proc_get_status() expects parameter 1 to be resource, boolean given in <b>/home/myuser/.composer/vendor/drush/drush/includes/startup.inc</b> on line <b>435</b><br />
<br />
<b>Warning</b>:  proc_close() expects parameter 1 to be resource, boolean given in <b>/home/myuser/.composer/vendor/drush/drush/includes/startup.inc</b> on line <b>436</b><br />
**************** Spanish site ******************
X-Powered-By: PHP/5.5.33
Content-type: text/html

<br />
<b>Warning</b>:  proc_open(): Descriptor item must be either an array or a File-Handle in <b>/home/myuser/.composer/vendor/drush/drush/includes/startup.inc</b> on line <b>434</b><br />
<br />
<b>Warning</b>:  proc_get_status() expects parameter 1 to be resource, boolean given in <b>/home/myuser/.composer/vendor/drush/drush/includes/startup.inc</b> on line <b>435</b><br />
<br />
<b>Warning</b>:  proc_close() expects parameter 1 to be resource, boolean given in <b>/home/myuser/.composer/vendor/drush/drush/includes/startup.inc</b> on line <b>436</b><br />
**************** Completed **********************

The strange thing is that when I manually run drush -v core-cron on any site, the cron run ends successfully. I really don't know where the problem comes from.

  • 1
    Looks like your cron script is using php-cgi instead of php-cli. Compare the environment variables, php and php.ini being used, etc. between the working and non-working users (cron user, vs. user you are using when manually running Drush). – greg_1_anderson Dec 6 '16 at 19:07
  • I forgot to mention that this cron script worked well with Drush 6 before. Would it have been able to work yet if there was a php-cgi / php-cli problem? – Roger-Ro Dec 6 '16 at 20:47
  • Probably not, but Drush 7 and earlier are unsupported; been a long time since I've used Drush 6. – greg_1_anderson Dec 7 '16 at 0:08
  • What about adding "php -v" as the first line of your script (after the shebang line of course), and then run the script through cron and manually - to verify which version of PHP is executed in each situation. – hansfn Dec 13 '16 at 16:48
2

I would suggest that instead of calling cd within your script, you either set up drush aliases or pass the --root and --uri parameters to the cron request.

/home/myuser/.composer/vendor/bin/drush -v --root=/home/myuser/public_html --uri=fr.mysite.com core-cron

That should make sure that drush is running in the right context.

You can also make sure that drush is running with the php that you would like by setting the DRUSH_PHP environment variable.

0

Following the comments to the question, I've added php -v as the first line of my script after the shebang line and run it both manually and through cron.

Manually, I've run sh myscript.sh and got:

PHP 5.5.33 (cli)

and the script's ended successfully.

Through cron, I've got:

PHP 5.5.33 (cgi-fcgi)

and the script's ended in failure.

So it's indeed a php-cgi / php-cli problem: cron is using php-cgi instead of php-cli in my case.

But since I'm hosted on a managed VPS and since I don't intend to use D6 for much longer, I've finally found easier to write another script using wget:

#!/bin/bash
# Script to execute all the cron jobs with wget
echo '**************** French site *******************'
wget --no-cache --spider http://fr.mysite.com/cron.php
echo '**************** English site ******************'
wget --no-cache --spider http://en.mysite.com/cron.php
echo '**************** Spanish site ******************'
wget --no-cache --spider http://es.mysite.com/cron.php
echo '**************** Completed **********************'

It's a little slower than using drush but it runs well.

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.