This is an update to the post CiviCRM / Wordpress cron no longer working under php8, grumbles ensue.
I followed a trail of crumbs (thank you, Nicol) to CiviCRM's Mattermost server. The initial thread presented didn't get me the full answer but I did manage to find something that helped me.
Someone mentioned that the wp-cli
was needed on certain installations. This nugget of information cost me most of the day so I figured I'd share in case someone else values their time more than I did.
Apparently something changed with later versions of Wordpress and CiviCRM where cli.php
and cv
silently fail. This, it appears, is because enough of Wordpress isn't instantiated to actually do the thing. But if you use wp
, which is the Wordpress command-line interpreter you get the whole of Wordpress initialized, which makes things work.
This is the command (note that the items with <...>
require you to substitute your own parameters):
/usr/bin/wp --user=cron --url=<url-with-https> --path=</fully/qualified/path> civicrm api job.execute auth=0
Suddenly things worked. It sat there doing what the other two commands wouldn't.
The final command I used was this:
/usr/local/bin/php /usr/bin/wp --user=cron --url=<url-with-https> --path=</fully/qualified/path> civicrm api job.execute auth=0 > /dev/null 2>&1
This doesn't overload the system email with warning messages (which I still haven't sussed out why they are appearing) and output that cannot be suppressed from the command itself. It also (on A2 Hosting and I suspect other installations) properly sets PHP_SAPI
to cli
instead of cgi-fcgi
. If you see this error then you'll need to find the right php
to run:
WP-CLI only works correctly from the command line, using the 'cli' PHP SAPI.
You're currently executing the WP-CLI binary via the 'cgi-fcgi' PHP SAPI. In
case you were trying to run this file with a web browser, know that this
cannot technically work. When running the WP-CLI binary on the command line,
you can ensure you're using the right PHP SAPI by checking that php -v
has
the word 'cli' in the first line of output.
Hopefully this will save someone else the hassle and give the right breadcrumbs to help fix this issue once-and-for-all.
I do love how CiviCRM integrates with and supports a lot of different platforms but it also makes issues like this vastly more complex to solve. Perhaps multiple Stacks Exchanges and chat platforms aren't the best ways to house the multitudes of work-arounds and band-aid solutions for said complex systems.