关于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& ...
随机推荐
- 启用Hyper-v后,重启后界面提示 无法完成功能配置,正在撤销更改
安装docker后,提示需要启用hyper-v,在控制面板中勾选Hyper-v,然后重启,更新快完成就提示无法完成功能配置,正在撤销更改 解决方法 方法1 控制面板一个一个选 方法2 百度了n多内容, ...
- 使min-height子元素height百分比生效的2种方式
方式1,使用flex <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...
- 什么是 Base64 ?
Base64 是什么? Base64是一种二进制到文本的编码方式.如果要更具体一点的话,可以认为它是一种将 byte数组编码为字符串的方法,而且编码出的字符串只包含ASCII基础字符,就是包括小写字母 ...
- DQL排序查询和DQL聚合函数
DQL:查询语句 排序查询 语法: order by 字句 order by 排序字段1 排序方式1,排序字段2 排序方式2... 排序方式: ASC:升序,默认的 DESC:降序 SELECT * ...
- Vue 基本列表 && 数据过滤与排序
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8" /> 5 & ...
- MySQL表操作过程的基础代码解析
GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. MySQL 的表有很多种,对表的操作主要是增删改查,今天来浅谈一下这些操作的底层代码和流程,以下以 tmp table为例 ...
- .NET 7 发布的最后一个预览版Preview 7, 下个月发布RC
微软在2022年8月9日 发布了.NET 7 Preview 7[1],这是它在11月10日 RTM 之前进入发布候选阶段之前的最后预览版. 预览版 7 已在 Visual Studio 17.4 预 ...
- 概述:基于事件的优化方法 / 事件驱动优化 / Event-Based Optimization / EBO
大家好,我是月出 本文基于这篇综述,介绍了 事件驱动优化(Event-Based Optimization, EBO). 事件驱动优化,是一种建模现实场景.做优化的思路,理论和 MDP / 强化学习很 ...
- 【NOI P模拟赛】大阶乘(斯特林数)
题意 求 16 16 16 进制下, n ! n! n! 去掉尾部 0 0 0 后取模 2 64 2^{64} 264 的结果. n < 2 64 n<2^{64} n<264 一共 ...
- ABC209F. Deforestation——DP(、数学容斥)
题面 有 n n n 棵树排成一排,每棵树高度为 h i ( i ∈ [ 1 , n ] ) h_i~(i\in[1,n]) hi (i∈[1,n]) ,你现在要按照一个排列 P P P 的顺序去砍 ...