AWS无法从Cronjob工作

编程入门 行业动态 更新时间:2024-10-25 04:18:34
本文介绍了AWS无法从Cronjob工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

因此,我有一个脚本,每天可以从AWS下载文件并将其附加到电子表格中.为此,我设置了一个cronjob.

So I have a script to download a file from AWS daily and append it to a spread sheet. To do this I have set up a cronjob.

当我手动运行该脚本时,该脚本可以正常运行,但是从cronjob运行时,该脚本不起作用.

The Script works fine when I run it manually, but does not work when running from the cronjob.

代码有一行:

aws s3 cp s3://My/files/backup/ ~/home/AnPoc/ --recursive --exclude "*.tgz" --include "*results.tgz"

在我从cronjob执行收到的电子邮件中,看到以下错误消息:

And in the email I recieve from the cronjob execution, I see the following error message:

./AnPoc/DayProcessing.sh: line 14: aws: command not found

我不知道为什么找不到该命令.任何帮助都会很棒.

I don't know why the command is not being found. Any help would be great.

推荐答案

首先:检查可执行文件aws在系统上的存储位置.使用以下命令:

First: check where on your system the executable aws is stored. Use this command:

$ which aws /usr/bin/aws # example output, can differ in your system

现在,在脚本前的crontab中放置一个名为$PATH的变量:

Now, place a variable called $PATH in your crontab before the script:

PATH=/usr/bin:/usr/local/bin

用:分隔的路径定义了在哪里搜索可执行表.在上面的示例中,它是/usr/bin.您必须检查cron作业中的所有可执行文件是否可用.

Those paths separated by : define where should be search for the exectable. In the example above it's /usr/bin. You have to check all executables in your cron job that they are available.

另一件事::请尝试避免在cronjobs中使用波浪号(~)进行路径操作.改为使用/home/user.

Another thing: try to avoid path with a tilde (~) in cronjobs. Use /home/user instead.

更多推荐

AWS无法从Cronjob工作

本文发布于:2023-07-16 04:10:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117700.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工作   AWS   Cronjob

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!