I am running an artisan command via the scheduler on elastic beanstalk.
Elastic beanstalk cronjobs need to be passed the environment variables required for the process as follows.
* * * * * ec2-user source /opt/elasticbeanstalk/support/envvars; php /var/app/current/artisan schedule:run >> /dev/null 2>&1
Where /opt/elasticbeanstalk/support/envvars
is a list of exports.
This works fine for the process running the scheduler itself, but the scheduler executes commands on separate processes and therefore the environment variables are missing.
For example
[ec2-user@ip-x-x-x-x current]$ php artisan schedule:run
Running scheduled command: '/usr/bin/php-7.0' 'artisan' rewards:notify > '/dev/null' 2>&1
Which then doesn't have access to the environment variables because the shell doesn't have a concept of a profile it seems and therefore doesn't autosource .bashrc
etc.
How can I get the environment variables from the aforementioned file to be read in before my commands?