我可以通过这个命令得到任务id。
$aws ecs list-tasks --cluster mycluster
{
"taskArns": [
"arn:aws:ecs:ap-northeast-1:142324134231:task/mycluster/44645ae88f294ed9af3f4d809b3f1721",
"arn:aws:ecs:ap-northeast-1:142324134231:task/mycluster/73af9f9645d2412bba1344bf0e362fd5"
]
}然后复制并粘贴任务id和exec命令。
aws ecs execute-command \
--cluster mycluster \
--task 44645ae88f294ed9af3f4d809b3f1721 \
--container DjangoContainer \
--interactive \
--command "/bin/bash"有什么办法自动做到这一点吗?
这是shell脚本的问题,或者它们在aws中有类似的功能吗?
(例如(它是假的))
$aws ecs list-tasks --cluster mycluster --show-taskonly
44645ae88f294ed9af3f4d809b3f1721因此,我当前的想法是使用php正则表达式从响应中获取id,并编写新命令。
不过听起来不太酷。
有什么好的做法吗?
发布于 2022-03-02 03:15:50
要只获取ID,可以使用-查询
aws ecs list-tasks --cluster JAJP1LFGTN075 --query "taskArns" --output texthttps://stackoverflow.com/questions/71316794
复制相似问题