EC2 instance scheduler [closed]
Questions asking us to recommend 开发者_Python百科or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this questionI would like to ask, what automatic tools are there to start Amazon EC2 instance at 08:00AM and stop it on 16:00 (And where to run it from?)
The company I work for had customers regularly asking about this so we've written a freeware EC2 scheduling app available here:
http://blog.simple-help.com/2012/03/free-ec2-scheduler/
It works on Windows and Mac, lets you create multiple daily/weekly/monthly schedules and lets you use matching filters to include large numbers of instances easily or includes ones that you add in the future.
I run my instances through a service called Scalarium - it has this time-based autoscaling. :)
Well to shut the servers down, you could just schedule a task on the server(s) itself to tell it to shutdown at 16:00.
However if you use the Amazon EC2 Command Line Tools you can run commands from your workstation to start and stop instances:
- http://docs.amazonwebservices.com/AWSEC2/latest/CommandLineReference/index.html?ApiReference-cmd-RunInstances.html
In order to set up the Command Line Tools on your workstation for Mac/Linux the following guides may be useful:
- http://www.robertsosinski.com/2008/01/26/starting-amazon-ec2-with-mac-os-x/
- http://cloud-computing.learningtree.com/2010/09/28/using-the-amazon-ec2-command-line-tools-and-api/
You could even configure these commands to run when you boot your workstation, or schedule them on your workstation.
Amazon doesn't offer any functionality to support this.
The preferred solution (at present) is to run a cron task from an existing server.
I'm not sure that there is, but I believe that a lot of people have interest in such a product. I've actually got a product that does the opposite of what you need -- it stops a machine after a predetermined amount of time ;-). My guess is that you're looking to save EC2 $$$ by running your instances only during daytime hours. If that's the case then I believe my existing product could easily be twisted to meet your needs.
You can do this by running a job on another instance that is running 24/7 or you can use a 3rd party service such as Ylastic or Rocket Peak.
If you want to set it up yourself, for example, in C# the code to stop a server is quite straightforward:
public void stopInstance(string instance_id, string AWSRegion) { RegionEndpoint myAWSRegion = RegionEndpoint.GetBySystemName(AWSRegion); AmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client(AWSAccessKey, AWSSecretKey, myAWSRegion); ec2.StopInstances(new StopInstancesRequest().WithInstanceId(instance_id)); }
精彩评论