I recently had an issue where my cron events weren’t firing, and after enabling email output, I ended up with something like this PHP error message:
Parse error: syntax error, unexpected '?' in /path/to/file.php on line 123
It turns out that WP-CLI was running PHP 5.x via the DreamHost cron system. I had PHP 7.x specific code in my theme.
To fix this, I had to set the
WP_CLI_PHP environment variable in my cron job: