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:

  Failed opening required 'CRM/Core/ClassLoader.php' (include_path='.::/packa

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.


  • How have you defined civicrm_root in civicrm.settings.php? It seems like it's blank.
    – Demerit
    Jan 15 at 7:51
  • @Demerit, $civicrm_root is set to /var/app/current/vendor/civicrm/civicrm-core - thanks for your help!
    – Steve
    Jan 17 at 8:33
  • Sorry I double checked and to clarify that there is a / at the end (/var/app/current/vendor/civicrm/civicrm-core/). Thanks!
    – Steve
    Jan 17 at 20:35
  • The reason I'm asking is because if you look at the lines where it sets the include_path, your include_path looks exactly like what it would look like if $civicrm_root was blank. Is there maybe a second place in the file where it's blanking out $civicrm_root?
    – Demerit
    Jan 18 at 17:19
  • 1
    If you had a line like $civicrm_root=$_ENV['something']; then it's possible that might work from your login shell but come out blank during cron.
    – Demerit
    Jan 18 at 21:55

1 Answer 1


The problem here was $civicrm_root being set in civicrm.settings.php based on an environment variable, which wasn't set during cron.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.