I'm trying to set up the CiviCRM cron job.
I've downloaded and installed wp-cli according to the instructions on
I have logged into the server as the user running the cron job.
I can successfully run this command in the shell:
/usr/local/bin/wp --url=https://<URL of Server>/ --path=/home/<userDir>/<hostingDir>/ civicrm api job.execute auth=0
But if I run the same command in cron it returns this error in the Cron email:
===============================
Set-Cookie: PHPSESSID=73sl011599lmjbg5038j5n06q4; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-type: text/html; charset=UTF-8
<br />
<b>Warning</b>: fwrite() expects parameter 1 to be resource, string given in <b>phar:///usr/local/bin/wp/php/WP_CLI/Loggers/Base.php</b> on line <b>61</b><br />
<br />
<b>Warning</b>: fwrite() expects parameter 1 to be resource, string given in <b>phar:///usr/local/bin/wp/php/utils-wp.php</b> on line <b>118</b><br />
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at phar:///usr/local/bin/wp/php/WP_CLI/Loggers/Base.php:61) in <b>/home/<userDir>/<hostingDir>/wp-includes/pluggable.php</b> on line <b>1216</b><br />
========================================
I've also run the whoami command via cron and it confirms that it's the same user running in the shell and the cron job.
Running wp --info in the shell gives this:
OS: Linux 3.10.0-514.21.2.el7.centos.plus.x86_64 #1 SMP Wed Jun 21 17:20:54 UTC 2017 x86_64
Shell: /bin/bash
PHP binary: /opt/cpanel/ea-php56/root/usr/bin/php
PHP version: 5.6.33
php.ini used: /opt/cpanel/ea-php56/root/etc/php.ini
WP-CLI root dir: phar://wp-cli.phar
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /home/<userDir>
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 1.5.0
=================================
Running wp --info in the cron job gives this:
OS: Linux 3.10.0-514.21.2.el7.centos.plus.x86_64 #1 SMP Wed Jun 21 17:20:54 UTC 2017 x86_64
Shell: /bin/bash
PHP binary: /opt/cpanel/ea-php56/root/usr/bin/php-cgi
PHP version: 5.6.33
php.ini used: /opt/cpanel/ea-php56/root/etc/php.ini
WP-CLI root dir: phar://wp-cli.phar
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /usr/local/bin
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 1.5.0
================
Now, the PHP binary paths are different. As is the WP_CLI phar path.
I'm assuming this may be the problem?
But I don't know why they are different, or how to reconcile them...
Any insights gratefully received.
Thanks, Norman