Jo Ko
Jo Ko

Reputation: 7575

How to run it during downtime?

Currently, when it eventually matches the time_defined then runs the code in the if statement.

Would like to put this. What would be the proper approach to doing so?

Also, any suggestions on optimization are welcomed as well.

Thank you in advance!

Upvotes: 3

Views: 126

Answers (2)

mangupt
mangupt

Reputation: 389

There are two things that you need to do for this. you need to create a wrapper script (let's say "wrap.py") as follows and set is in crontab for the AWS Server:

#!/usr/bin/python

python your_script_path.py

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

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

Update: add cron job running "crontab -e" on 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)

Upvotes: 0

E.J. Brennan
E.J. Brennan

Reputation: 46849

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

What is Amazon CloudWatch Events?

Amazon CloudWatch Events delivers a near real-time stream of system events that describe changes in Amazon Web Services (AWS) resources to Amazon EC2 instances, AWS Lambda functions, Amazon Kinesis streams, Amazon ECS tasks, Step Functions state machines, Amazon SNS topics, Amazon SQS queues, or built-in targets. Using simple rules that you can quickly set up, you can match events and route them to one or more target functions or streams.

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

Upvotes: 1

Related Questions