How to regularly clean up hung Fargate tasks

0

I have identical ECS clusters spread across several AWS regions. They are configured to run a short running fargate task on demand. Sometimes these tasks do not complete; they "hang" in the running state.

I'm going to figure out why that happens separately, what I'd like to do as a stopgap is to regularly purge tasks that have been running for longer than an hour for example.

It looks like I can do this with systems manager; run a script that goes and gets all running tasks from the cluster in each region, then stop those that have been running for too long. Will this work, and is there a better way to do this?

已提問 2 年前檢視次數 203 次
1 個回答
1
已接受的答案

Sure, it's possible to have an external process like an SSM document or a lambda that finds and kills them. But I would probably only use the timeout util in the startup command when you start your app. https://linuxize.com/post/timeout-command-in-linux/

the command would look something like this: timeout 3600 start service.

Hope it helps!

profile picture
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南