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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ