因此,我有一个脚本,每天可以从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工作
发布评论