<p>AWS Lambda should be an obvious choice together with a a CloudWatch Event trigger <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/RunLambdaSchedule.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/RunLambdaSchedule.html</a> .</p>
<p>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).</p>
<p>Running a Fargate task - may be reasonable as well.</p>
<p>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 .</p>

CC BY-SA 4.0
2021-12-16T18:16:27.313Z
GCP's answer to Lambda is Cloud Functions. You find find them in the console under "Serverless"
code_monk
CC BY-SA 4.0
2021-12-19T19:25:07.337Z
you can utilize, kubernetes `jobs` as well.
AATHITH RAJENDRAN
CC BY-SA 4.0
2021-12-12T22:22:05.930Z
2021-12-12T22:22:05.930Z
petrchpetr
<p>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.</p>
<p>But I was wondering if there's a better (cleaner) way to do this</p>
<p>Also I was wondering how to do the same but on Google Cloud as well as AWS</p>

CC BY-SA 4.0
2021-12-12T13:31:40.803Z
Update: I found this Google Cloud article that has a good explanation. https://cloud.google.com/blog/products/application-development/how-to-schedule-a-recurring-python-script-on-gcp
Aayush Agrawal
<amazon-web-services><gcp>
How do I setup a script to run on a schedule in a clean & professional way?
Aayush Agrawal
# How do I setup a script to run on a schedule in a clean & professional way?

(Asked by: username_0 on 2021-12-12)

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

**Tags:** amazon-web-services, gcp

> **Comments:**
> **username_0**: Update: I found this Google Cloud article that has a good explanation. https://cloud.google.com/blog/products/application-development/how-to-schedule-a-recurring-python-script-on-gcp  

---

## 1 answers

### Answer by username_1 on 2021-12-12. Score: 3 | Accepted answer

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 .

> **Comments:**
> **username_2**: GCP's answer to Lambda is Cloud Functions. You find find them in the console under "Serverless"  
> **username_3**: you can utilize, kubernetes `jobs` as well.  

---

