How do I start it while idle?

Currently, when it ultimately matches time_defined

, then the code in the if statement is executed.

I would like to put this. What would be the correct approach to this?

Any suggestions for optimization are also welcome.

Thank you in advance!

+3


source to share


2 answers


The best and easiest way to do this is to convert your python function to python function for AMS AWMS (easy) and then use AWS Cloudwatch events to trigger the function at whatever time interval you want (also easy).

What are Amazon CloudWatch Events ?

Amazon CloudWatch Events provides a near-real system stream of events describing changes to Amazon Web Services (AWS) resources for Amazon EC2 Instances, AWS Lambda Functions , Amazon Kinesis Streams, Amazon ECS Tasks, Step Functions end machines, Amazon SNS topics, Amazon SQS or built-in goals. Using simple rules that you can quickly customize, you can map events and route them to one or more target functions or streams.



http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/WhatIsCloudWatchEvents.html

+1


source


There are two things you need to do for this. you need to create a wrapper script (say "wrap.py") like this and set in the crontab for the AWS server:

#!/usr/bin/python

python your_script_path.py

      

the first line mentions the python path in your AWS Server installation, with the second line mentioning your name of the script you want to run.



Please follow below: https://superuser.com/a/682142 for more details.

Update: add a cron job executing "crontab -e" in the shell

*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of        month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)

      

0


source







All Articles