关于aws cli命令的exit/return code分析
最近总是收到一个备份脚本的失败邮件,脚本是之前同事写的,没有加入任何有调试信息,及有用的日志
于是去分析 ,脚本中有一条 aws s3 sync $srclocal $dsts3 命令,然后根据这条命令的执行状态码判断成功与失败
失败后,会发送失败的提醒邮件,然后去s3界面去看,s3 sync备份任务又好像是的成功的,主要的核心的备份文件都是在的
难道是部分文件备份失败,于是加入调试信息,输出stderr信息及exit code,最后return code 为 2
最后,去查询了一下,aws cli相关的文档,AWS CLI Return Codes, 有一段说明如下:
These are the following return codes returned at the end of execution of a CLI command: 0 -- The service responded with an HTTP response status code of 200 and
there were no errors from either the CLI or the service the request was made to. 1 -- Limited to s3 commands, at least one or more s3 transfers failed for the command executed. 2 -- The meaning of this return code depends on the command being run.
The primary meaning is that the command entered on the command line failed to be parsed.
Parsing failures can be caused by, but are not limited to, missing any required subcommands
or arguments or using any unknown commands or arguments. Note that this return code meaning is applicable to all CLI commands. The other meaning is only applicable to s3 commands.
It can mean at least one or more files marked for transfer were skipped during the transfer process.
However, all other files marked for transfer were successfully transferred.
Files that are skipped during the transfer process include: files that do not exist,
files that are character special devices,block special device, FIFO's, or sockets, and files that the user cannot read from. 130 -- The process received a SIGINT (Ctrl-C). 255 -- Command failed. There were errors from either the CLI or the service the request was made to.
官方文档参考:https://docs.aws.amazon.com/cli/latest/topic/return-codes.html
对于2的返回码分析,加之输出的调试信息分析 ,发现用户对某一个文件,没有读的权限
[qq_5201351@localhost tmp]$ cat Project_s3sync_stderr.log
warning: Skipping file /backup/db-backup.20211108.tar. File/Directory is not readable.
解决方法:对于这个文件,给执行备份脚本的用户加上读权限即可~
另:在生产环境中,笔者还会遇到exit code 为1的情况,查询日志如下:
upload failed: ../../dir/.log.16 to s3://qq5201351/.log.16 [Errno 2] No such file or directory: '/dir/.log.16'
笔者检查了一下,其他文件是正常的,这种情况一般就是少数的文件传输失败
而且笔者这里的场景,很可能这个文件在当时是有变化的,如临时缓存文件完成后重命名了,所以找不到了
尊重别人的劳动成果 转载请务必注明出处:https://www.cnblogs.com/5201351/p/15523673.html
关于aws cli命令的exit/return code分析的更多相关文章
- AWS Switching to an IAM role (AWS CLI)
一,引言 今天额外分享一篇 AWS 的技术内容,需要在 EC2 切换到跨账号 IAM 角色(AWS CLI).假设我们使用两个 AWS 账户,A账号,B账号.我们希望允许 A 账号用于 "i ...
- AWS CLI以及AWS S3 SYNC命令行使用
1.到AWS的IAM创建用户,并且获取到访问密钥 ID 和私有访问密钥.下载密钥并保存. 2.到http://docs.amazonaws.cn/cli/latest/userguide/instal ...
- 报错,但不影响运行ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
参考:http://blog.csdn.net/zxl0016/article/details/7327125 eclipse 3.4+jdk1.6 编译正常通过,运行debug模式时报错 ERROR ...
- Hive的Shell里hive> 执行操作时,出现FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask错误的解决办法(图文详解)
不多说,直接上干货! 这个问题,得非 你的hive和hbase是不是同样都是CDH版本,还是一个是apache版本,一个是CDH版本. 问题详情 [kfk@bigdata-pro01 apache-h ...
- 为你的AliOS Things应用增加自定义cli命令
摘要: 怎么才能在RTOS系统中,通过 串口shell控制LED的开关. 在日常嵌入式开发中,我们经常会用串口命令来使设备进入某种特定的状态,或执行某个特定的操作.如系统自检,模拟运行,或者进入手动模 ...
- golang常用库:cli命令行/应用程序生成工具-cobra使用
golang常用库:cli命令行/应用程序生成工具-cobra使用 一.Cobra 介绍 我前面有一篇文章介绍了配置文件解析库 Viper 的使用,这篇介绍 Cobra 的使用,你猜的没错,这 2 个 ...
- Hive创建表格报【Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException】引发的血案
在成功启动Hive之后感慨这次终于没有出现Bug了,满怀信心地打了长长的创建表格的命令,结果现实再一次给了我一棒,报了以下的错误Error, return code 1 from org.apache ...
- [Notes] AWS Automation using script and AWS CLI
(c) 2014 Amazon Web Services, Inc. and its afflialtes, All rights reserved. The content in this file ...
- AWS CLI 中使用S3存储
登录 通过控制面板, 在S3管理器中创建一个新的bucket 所有AWS服务 -> 安全&身份 -> IAM -> 组, 创建一个新的组, 例如 "s3-user& ...
随机推荐
- else语句
else的搭配 与else语句配合使用有三种情况 if ...: else: if条件表达式不成立的时候执行else 注意else还可以与while循环和for循环组合在一起(这是一个全新的知识) 注 ...
- nginx的高级用法
一.根据url中的参数来确定缓存的key set_by_lua_block $dataArg { local enc = ngx.req.get_uri_args()["enc"] ...
- 整除分块套杜教筛为什么是 O(n^2/3) 的
假设我们要筛一个东西叫做 \(f\) . 记 \[D(n)=\left\{n,\left\lfloor\dfrac n2\right\rfloor,\left\lfloor\dfrac n3\righ ...
- 丽泽普及2022交流赛day16 社论
这场比较平凡吧 . 省流: http://zhengruioi.com/contest/1087 目录 目录 A. Gene 题面 题解 算法一(正解) 算法二 B. Fight 题面 题解 算法一( ...
- qbxt数学五一Day4
目录 1. 随机试验 2. 概率 1. 平凡 2. 条件概率 3. 期望 习题 1 2 3 4 1. 随机试验 定义: 不能预先确知结果 试验之前可以预测所有可能结果或范围 可以在相同条件下重复实验 ...
- Vue3.0工程创建 && setup、ref、reactive函数 && Vue3.0响应式实现原理
1 # 一.创建Vue3.0工程 2 # 1.使用vue-cli创建 3 # 官方文档: https://cli.vuejs.org/zh/guide/creating-a-project.html# ...
- Postgres常用SQL
- if条件控制语句和switch语句
if条件控制语句(判断范围,在一定区间内容进行判断) if 如果(第一个条件) else if 如果(第二个条件 可以无限加) else 否则(只能有一个 上面都不满足的情况下进入) if和else ...
- 3052 [USACO12MAR]摩天大楼里的奶牛Cows in a Skyscraper (状压DP,IDA*)
状压DP: #include <iostream> #include <cstdio> #include <cstring> #include <algori ...
- MySQL 连接超时:报错SQLSTATE[HY000] [2002] Connection timed out
在网上找了一堆,结果全部是错的 后来,我明白了其实是设置问题. 当你的代码部署到服务器里的时候,你的mysql 的host 值 应该为 127.0.0.1 而不是 你的服务器ip 不然就会报错. 其实 ...