I am having an issue in Amazon Linux 2 where I can run cv commands from the command line but I cannot run cv commands from cron.
For example:
/usr/bin/php /usr/local/bin/cv api job.execute --user=cronusersupport --cwd=/var/app/current
This command will run perfectly from the command line using the default ec2-user account. Running this command from cron while logged in as the same user will produce:
In civicrm.settings.php line 569:
[Error]
Failed opening required 'CRM/Core/ClassLoader.php' (include_path='.::/packa
ges:.:/usr/share/php:/usr/share/pear')
I have been logging the output to a file. So my actual crontab looks like this:
*/15 * * * * /usr/bin/php /usr/local/bin/cv api job.execute --user=cronusersupport --cwd=/var/app/current -vvv >> /opt/paao_civi_cron.txt 2>&1
I have even tried adding cd /var/app/current &&
before this command to make sure the command is running from the correct place.
I have checked the verbose output and the last step that works correctly is [Bootstrap:debug] Load settings file "/var/app/current/web/sites/default/civicrm.settings.php"
.
I have worked with AWS support on this and we tried things like making sure my $PATH was correct, running the command as an sh script, trying to run as the webapp user who owns the files, and I have even added the $civicrm_root to line 569 of civicrm.settings.php to see if that would work.
I have the following config:
EC2 instance with remote RDS server. The server is running well for HTTP requests and cv commands when not run from cron.
Drupal - 9.5
CiviCRM -5.64.4
CV - 0.3.48
PHP - 8.0.30
If anyone has any ideas I would be very thankful as I am at a loss here.
I have the same setup working on Ubuntu and it is working perfectly.
Thanks!
$civicrm_root=$_ENV['something'];
then it's possible that might work from your login shell but come out blank during cron.