开发者

how to make a script be active for only on every hour on the half hour?

I have a script and I want to code it so that it becomes active e开发者_高级运维very 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.


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


You can use cron jobs. Schedule it for every 1 hr. starting at 00:30:00.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜