On 28/02/2019 14:45, nathan tech wrote: > but I'm thinking, should I do this?
No. fOr several reasons... > def do_backup > # backup code here, > > def scheduler(): > global tus # tus=time until schedule > > while(time.time()>tus): > time.sleep(5) > scheduler() scheduler doesn't actually do anything except spin waiting for the time up. But you know the current time and the due time so you can just sleep until the due time, no need for the loop. Also you exit the loop and then call scheduler again - that will immediately exit the loop and call scheduler again which will repeat "forever". I suspect you meant to call do_backup? However, if you really want to delay execution of do_backup you can probably do it via the OS Nearly every OS has a means of scheduling tasks. So, by splitting your app into two parts - one to create the scheduled task and the other to actually do the backup. That way the OS does all the heavy lifting, including restoring the schedule after an OS restart etc. And you only have the relatively easy task of telling the os to schedule a task and writing the backup function. > This is a program for windows. OK, I cant recall the Windows schedule program - I think it was "at" or somesuch? Then again you could just use the native Windows backup program which doe it all for you... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor