HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How do I setup a script to run on a schedule in a clean & professional way?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
scriptprofessionalwaysetuphowschedulerunclean

Problem

I have a small python piece of code that I want to run on a schedule. The dirty way to do it would be to just spin up an EC2 instance and use CRON to run the script.

But I was wondering if there's a better (cleaner) way to do this

Also I was wondering how to do the same but on Google Cloud as well as AWS

Solution

AWS Lambda should be an obvious choice together with a a CloudWatch Event trigger https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/RunLambdaSchedule.html .

Running an EC2 instance may be reasonable in some scenarios as well. It would make sense for me if the trigger for example did some complex data manipulation on a reasonable small data set (fitting in memory on a bigger spot multi-core instance or something like that).

Running a Fargate task - may be reasonable as well.

If it is something close to the gcloud example I would go with Lambda + CloudWatch Event. All of this can be easily defined via CloudFormation template .

Context

StackExchange DevOps Q#15102, answer score: 3

Revisions (0)

No revisions yet.