0 votes
1 view
in AWS by (12.9k points)

Is there a way that Amazon Web Services EC2 instances can be self terminating? Does Amazon have anything that allows an instance to terminate itself ("Hara-Kiri") after running for more than say an hour? I could change the scripts on the running instance to do this itself, but that might fail and I don't want to edit the image, so I would like Amazon to kill the instance.

1 Answer

0 votes
by (18.6k points)

To set up auto termination for your instance, follow the below-mentioned steps:

1. Start the instances with the "instance -initiated-shutdown-behaviour set to "terminate"

2. SSH into your instance and Login as the root user

3. Run the following command:

echo "sudo halt" | at now + 55 minutes

Now your instance will self terminate after 55 minutes

Welcome to Intellipaat Community. Get your technical queries answered by top developers !