I have a cronjob that calls a rails task that needs access to environment variables (S3 credentials). I have the environment variables set in my .bashrc and I can run the task from the command line, the cronjob though fails due to missing credentials.
If I add the credentials to the crontab then the cronjob executes successfully. My crontab is generated with the whenever gem so I have added the S3 credentials in my schedule.rb like so:
# aws credentials
env :AWS_S3_KEY, ENV['AWS_S3_KEY']
env :AWS_S3_SECRET, ENV['AWS_S3_SECRET']
Is there a way for cron jobs to access the environment variables without specifically setting them in the crontab file while still using the whenever gem?