问题
I've created a linux box that has a very simple make bucket command : was s3 mb s3://bucket
running this from the prompt works fine.
I've run AWS configure as both the user I'm logged in as and sudo. The details are definitely correct as the above wouldn't create the bucket.
The error message I'm getting from cron is :make_bucket failed: s3://cronbucket/ Unable to locate credentials
I've tried various things thus far with the crontab in trying to tell it where the credentials are, some of this is an amalgamation of other solutions which may be a cause of the issue.
My crontab look like :
AWS_CONFIG_FILE="/home/ec2-user/.aws/config"
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binx
0 0 * * * /usr/bin/env bash /opt/foo.sh &>> /tmp/foo.log
* * * * * /usr/bin/uptime > /tmp/uptime
* * * * * /bin/scripts/script.sh >> /bin/scripts/cronlogs/cronscript.log 2>&1
initially I just had the two jobs that were making the bucket and then creating the uptime (as a sanity check), the rest of the crontab are solutions from other posts that do not seem to be working.
Any advice is much appreciated, thank you.
回答1:
The issue is that cron doesn't get your env. There are several ways of approaching this. Either running a bash script that includes your profile. Or a nice simple solution would be to include it with crontab. (change profile to whatever you are using)
0 5 * * * . $HOME/.profile; /path/to/command/to/run
check out this thread
来源:https://stackoverflow.com/questions/36938991/crontab-cannot-find-aws-credentials-linuxbox-ec2