How can I make a program automatically run once per day?

baloan baloand at googlemail.com
Wed Jul 27 04:41:25 EDT 2011


On Jul 14, 7:00 pm, monkeys paw <mon... at joemoney.net> wrote:
> On 7/9/2011 10:01 PM, John Salerno wrote:
>
> > Thanks everyone! I probably should have said something like "Python,
> > if possible and efficient, otherwise any other method" ! :)
>
> > I'll look into the Task Scheduler. Thanks again!
>
> You could use the below code. time.sleep(# seconds in a day)
> where i == 30 would run once a day for a month
>
> import time
> i=0
> while (1):
>         print 'hello'
>         time.sleep(2)   # Change this to number of seconds in a day
>         if (i == 3):    # make this 30 for a month
>                 break
>         i = i + 1

This looks like a bad idea to me: to make it work throughout the year
you need to adjust for daylight savings start and end; this is where a
day does not have 24 hours - and, of course, daylight savings depends
on country settings of your host system...

Andreas
baloan at gmail.com



More information about the Python-list mailing list