EvilZone

Programming and Scripting => Scripting Languages => : pyte January 22, 2013, 10:39:28 AM

: python sheduled tasks scripting
: pyte January 22, 2013, 10:39:28 AM
im trying to make some scripts execute at intervals in order to execute a task.
below is the code I've managed to write but still cant find much to brag about,
any help on how to do this will be appreciated.

:
import time
>>> def t():
...    print"ill be back in an hour"
...
>>> if  __name__=="_main_":
...      while True:
...            t()
...            time.sleep(3600)

: Re: python sheduled tasks scripting
: vezzy January 23, 2013, 12:20:17 AM
Import the scripts as modules and call each function you need separately? From the short snippet you've given here, it seems you simply want to delay execution time in between, for which time does work. More background info on what exactly this is for?
: Re: python sheduled tasks scripting
: techb January 23, 2013, 03:11:26 AM
Yes, the script you posted will block until execution.
: Re: python sheduled tasks scripting
: pyte January 23, 2013, 11:11:53 AM

Import the scripts as modules and call each function you need separately? From the short snippet you've given here, it seems you simply want to delay execution time in between, for which time does work. More background info on what exactly this is for?




im trying to write a simple script that will be browsing through my Downloads folder forwarding every new thing that gets into the folder at an hours interval.
more like an auto backup for my downloads.
: Re: python sheduled tasks scripting
: Kulverstukas January 23, 2013, 01:46:54 PM
Maybe you should be using threads instead of blocking the main thread...