Reputation: 15862
I have a script and I want to code it so that it becomes active every hour on the half hour. This is the code I have so far.
from ConfigParser import *
import emailModule
from datetime import datetime
import time
configuration = ConfigParser()
configuration.read('Email.conf')
email = emailModule.emailModule(configuration)
while(True):
if (datetime.now().minute > 28 and datetime.now().minute < 32):
email.emailWeather()
time.sleep(3000)
I am just wondering is there a better way of doing this in python? IE a more efficient way or more reliable way of doing things.
Upvotes: 0
Views: 291
Reputation: 3808
If you are using linux, or any other system with a cronlike daemon, you could ask the system to run your script every hour on the half hour by putting a line like this in your crontab: 30 * * * * /path/to/script
Upvotes: 2