0
Scheduling execution of Python scripts at given time every day.
I made a newsletter script using python that generates a HTML source compatible with Email. I made another another python script to send this email. Now, I need to automate this email sending at, say, 7 AM everyday. I have tried using windows task scheduler. But it works only if my laptop is on at that time. Can anyone suggest any other way to do this?
3 ответов
+ 2
If you don't want to depend on your laptop to be online, then the best thing to do would be to deploy it as an online service. There are websites where you can do this, even for free within certain limits. I suggest to check Heroku, they even have a scheduler service:
https://elements.heroku.com/addons/scheduler
+ 1
You can have the program run constantly and use the time module to schedule it. You use that script to excecute the command whenever the time arrives
+ 1
import time
import datetime
import [modules you wrote]
while True:
if datetime.datetime.now().hours == 7:
[run script]
# loop every half-hour or so
time.sleep(1800)