0
我想要實現這樣的事情:我正在創建卷的快照(使用amazon ec2工具),並且將最新快照的詳細信息存儲在文件中。如何在代碼塊之間插入等待
#Create snapshots of all attached volumes
echo "Create snapshots of all attached volumes"
read -rsp $'Press enter to continue...\n'
awk '{print $2, $3}' "$EC2_HOME/ActiveVolumes_$today_date" | while read vol_id inst_id; do
awk '{print $3, $5}' "$EC2_HOME/Instances_$today_date" | while read inst_id2 name; do
if test "$inst_id" = "$inst_id2"; then
echo ec2-create-snapshot "$vol_id" -d "$today_date: Daily Backup for $inst_id (VolID:$vol_id InstID:$inst_id)"
ec2-create-snapshot "$vol_id" -d "$today_date: Daily Backup for $inst_id (VolID:$vol_id InstID:$inst_id)"
fi
done
done
#Create a file with all latest snapshots
echo "Create a file with all latest snapshots"
read -rsp $'Press enter to continue...\n'
latestdate=$(ec2-describe-snapshots | grep ^SNAPSHOT | sort -rk 5 | awk '{print substr($5, 1, 10); exit}')
ec2-describe-snapshots | grep "^SNAPSHOT.*$latestdate" > "$EC2_HOME/SnapshotsLatest_$today_date"
我想做一件事。我想根據一個條件在兩個代碼塊之間等待。我想在第一個代碼塊執行後等待。我想檢查狀態是否完成,然後執行下一個代碼塊。
SNAPSHOT snap-7749 vol-86d0 pending 2013-12-11T04:17:57+0000 100% 109030037527 35 EBS_Automated_Snapshot_12-10-2013-20:20:13
SNAPSHOT snap-e2f3dc vol-80 completed 2013-12-11T04:16:49+0000 100% 109030037527 35 EBS_Automated_Snapshot_12-10-2013-20:19:05
你爲什麼要發佈[同樣的問題](http://stackoverflow.com/questions/20513092/how-to-insert-a-wait-until-a-specific-condition-is-met-in-linux )再次?爲什麼不編輯較早的版本以包含更多信息? – devnull
@devnull:我刪除了較早的一個 – user3086014
您在等待/完成時顯示的信息來自哪裏?它是否在更新的文件中?這是你運行命令的結果嗎? – John1024