Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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.2k 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

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer

Browse Categories

...