0

I have tried many things but not able to save my files.

I have an account in aws and I have created an autoscaling group.I want to copy my log files to s3 but when any of the server deleted through autoscaling my 30 minutes log files loss so I have to run a script that runs on the time when the current server going to terminate due to autoscalling but I am unable to figure out that how I know or how to know that which server is going to delete with autoscalling ?

Is there any way to find out which server is going to delete using autoscalling ?

2 Answers 2

0

If I understand well, you want to know how AWS determines which instance will be nextly terminated by an autoscaling group? Within an autoscaling group, there is a termination policy, which is the way AWS knows which instance to terminate when it comes to removing VMs (you can choose which policy to apply)

2
  • Yes exactly @tom but i want to tell this to that server which is going to be deleted so that it will be able to run my backup script. so how my server know about that it is going to deleted is there any way to inform that server so that it will be able to run my backup script before deleting and I will recover my log files loss ? Aug 11, 2015 at 14:08
  • the only way I know about this is using hooks, but this is not trivial: docs.aws.amazon.com/fr_fr/AutoScaling/latest/DeveloperGuide/… Maybe you there is some trick using lambda or SWF, in that case I would be happy to hear about it :)
    – Tom
    Aug 11, 2015 at 15:32
0

I think your best chance is to write an init script to mock a "service" that performs the upload tasks on stop command. Then, simply configure properly your rc so your script is called on a shutdown event.

Anyway, shutdowns can't last forever. Most linux distributions have a "grace period" of 5-10 minutes to wait for services to stop gracefully before starting to kill processes. If you accumulate too much files this approach may not be enough, but if you also perform uploads on log rotation events this should not be an issue.

Now, to tell which of your instances will be terminated next, you may get to figure it out through the EC2 and Autoscaling APIs (though it may not fit your use case exactly). All you need is to configure your autoscaling group to terminate oldest or newest instances first so you can describe your ec2 instances and retrieve all of their launch times and sort the output the proper way to get your "queue of death".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .