Reputation: 418
I seek a method to implement a cron-like system on AWS EC2 instance : every morning, I have some tasks to run, and they are using a lot of RAM (about 8 Go for each script). I don't want to pay a full-time c4.2xlarge
instance, that's the point.
What I think about :
c4.2xlarge
instanceHow to automate these actions ?
Upvotes: 3
Views: 1516
Reputation: 6120
Simple..
Just Create a c4.2xlarge Instance with all the Configuration Defined.
While you launch the instance, Create a “user-data script” in the advanced tab, So that it runs the script after launch of the instance and issues a terminate command to itself after the job is done..
To call the launching script, you can set a cron job either locally or use aws lambda.
Upvotes: 0
Reputation: 9411
If you created an instance with --instance-initiated-shutdown-behavior terminate
then it will terminate itself when stopped. All you need to do is run shutdown -h now
at the end of your script when it's done.
So how do you start an instance at a specific time?
OR
cron
in the cloud that can run a Lambda function, which in turn may start you instance.Upvotes: 2
Reputation: 78663
Not sure what you intend to do in your cron scripts, but look at AWS Lambda scheduled events.
Note that Lambda does not natively support PHP, but there appear to be options. Personally, I'd consider rewriting it in Python or JavaScript if possible.
Upvotes: 2