Home > Enterprise >  What is the best way to schedule a python script with AWS?
What is the best way to schedule a python script with AWS?

Time:09-20

I have a question that I would like to solve:

I have 4 python scripts as follows:

  • main.py
    • script1.py
    • script2.py
    • script3.py

Scripts 1, 2 and 3 are run invoked in the main.py.

What I need is to be able to easily schedule this main.py to run once a week.

What AWS services would be best for this? From the architecture side I don't know much.

Thank you!

CodePudding user response:

You can deploy the script in lambda if your execution time is under 15 minutes plus cloudwatch events for scheduling

For execution scripts > 15 minutes, I would suggest using AWS Batch to have the script on schedule on any of the supported compute environment like ECS or EC2

CodePudding user response:

Use Schedule AWS Lambda Functions Using CloudWatch Events

  • Create Lambda functions - Deploy these scripts as single lambda function.
  • Create EventBridge ridge rule - with lambda as a target Event Source, do the following:Choose Schedule.Choose Fixed rate of and specify the schedule interval (for example, 5 minutes), also as @luk2303 mentioned you can also use cron expressions.
  • Use target as lambda created in 1st step.

Use this website for your cron needs https://crontab.guru

  • Related