class IgnoreList(list):
def append(self, item, *args, **kwargs):
if item == '.':
return
return super(IgnoreList, self).append(item)
这里循环永远不会退出, 即使执行了自动化并且状态不是正在进行中,它也会继续打印“自动化正在运行......” 我想做的就是等到状态为“进行中”,在屏幕上打印“自动化正在运行...”。 完成后,如果失败或成功,我想在屏幕上打印自动化状态。
答案 0 :(得分:1)
添加一个if,直到帮助我退出循环。
until [ $(aws ssm get-automation-execution --automation-execution-id "$id" --query 'AutomationExecution.AutomationExecutionStatus' --output text) = *"InProgress"* ];
do
echo "Automation is running......"
sleep 10s
if [ $(aws ssm get-automation-execution --automation-execution-id "$id" --query 'AutomationExecution.AutomationExecutionStatus' --output text) != "InProgress" ]; then
echo "Automation Finished"
status=$(aws ssm get-automation-execution --automation-execution-id "$id" --query 'AutomationExecution.AutomationExecutionStatus' --output text)
echo "Automation $status"
if [$status != "Success"]; then
exit 3
echo "Automation $status"
fi
break
fi
done