Running script on AWS server

I have a script that I need to run once a day, which requires a lot of memory. I would like to run it in a special amazon field.

Is there some kind of automated way to create a window, download all the necessary software (like ruby), and then run my script. After running the script, I would like to close the window.

Two possible options:

  • I am thinking of hacking an EMR for this. (My script is mapping to an empty directory)
  • Chef - this seemed too big for one simple script.
+6
source share
1 answer

You can configure a new instance of EC2 at startup using official Ubuntu AMIs, official Amazon Linux AMIs, and any other AMI that supports the user data script concept.

Create a script (bash, Perl, Python,

  • anything) that starts with C #!
  • Pass this script as user data when starting the EC2 instance.
  • The script starts automatically with root privileges on first boot.

Here's an article in which I introduced the concept of user data script:

Automate the installation of an EC2 instance using user data scripts
http://alestic.com/2009/06/ec2-user-data-scripts

Your user script data can install the necessary software, configure it, install your script work, and set up a cron job that runs the script once a day.

GAIN:

If the installation of the script does not take much time (for example, less than an hour or several), you do not even need to run a separate dedicated instance 24 hours a day. Instead, you can use an approach that allows AWS to run the instance for you on a regular schedule.

The article I wrote contains detailed information about this approach using sample commands:

Starting EC2 instances in a recurring schedule with automatic scaling
http://alestic.com/2011/11/ec2-schedule-instance

A general approach is to use automatic scaling to run an instance with user script data on a regular schedule. Your work will finish the instance when it is completed. They should suspend the usual desire for automatic scaling to restart instances that end so that you do not pay for the instance that is running until the next run of the job.

+9
source

Source: https://habr.com/ru/post/915522/


All Articles