Crontab找不到AWS凭证-linuxbox EC2 [英] Crontab cannot find AWS Credentials - linuxbox EC2

查看:144
本文介绍了Crontab找不到AWS凭证-linuxbox EC2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个具有非常简单的make bucket命令的linux框:在提示符下运行 s3 mb s3:// bucket 可以正常工作。



我已经以同时登录的用户身份和sudo身份运行AWS configure。详细信息绝对正确,因为上面不会创建存储桶。



我从cron收到的错误消息是:make_bucket失败: s3:// cronbucket /无法找到凭据



到目前为止,我已经使用crontab尝试了各种尝试来告诉它在哪里凭据是,其中一些是其他解决方案的合并,可能是造成此问题的原因。



我的crontab看起来像:

  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

我最初只有两个那些正在赚钱,然后创造正常运行时间的工作(作为健全性检查),其余的crontab是其他似乎无效的帖子的解决方案。



解决方案

问题是cron无法获取您的环境。

有几种解决方法。运行包含您的个人资料的bash脚本。或者,一个很好的简单解决方案是将其包含在crontab中。 (将配置文件更改为您正在使用的任何内容)

  0 5 * * *。 $ HOME / .profile; / path / to / command / to / run 

查看此线程


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.

解决方案

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

这篇关于Crontab找不到AWS凭证-linuxbox EC2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆