我进行了很多搜索,发现很多人在使用Cron和AWS CLI时遇到相同的问题,但是没有一个解决方案对我有用。
我尝试重新配置IAM,提供完整的路径信息,并在脚本中明确定义了$HOME
和$PATH
变量。
以下是脚本:(简体)
export HOME=/root
export SHELL=/bin/bash
export PATH=/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:/usr/local/git/bin:/root/bin:/usr/local/git/bin:/root/bin
echo "-------- Batch Moving to S3 -------- "
/root/.local/bin/aws s3 cp "$TMPDIR" "s3://$BUCKET/$DATE/accounts/" --exclude '*' --include '*.tar' --recursive� &>aws.log 2>&1
在终端上工作精美。但是,当它在cron中运行时,所有地狱破坏都会丢失。
aws.log
显示如下:
/root/.local/lib/python2.6/site-packages/urllib3/util/ssl_.py:369: SNIMissingWarning: An HTTPS request has been made, but the SNI (Server Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
SNIMissingWarning
upload failed: ./package.tar to s3://BUCKET/2018-10-14/accounts/package.tar can't start new thread
SNIMissing的最高警告似乎也发生在Terminal中,因此我认为这不是转移到CRON时的根本问题。
但是另一个错误:can't start new thread
-似乎是Python问题(并且AWS CLI在Python中运行)。
我正在通过Crontab调用脚本(现在每10分钟运行一次以进行调试,否则每周一次)。
*/10 * * * * /backupTmp/backup.sh >> /backupTmp/backup.log 2>&1
我已经检查了权限,
/root/.local/bin/aws
是root
拥有的可执行文件。
我正在使用Python 2.6
还有其他我可能会想念的东西吗?