Author Topic: python sheduled tasks scripting  (Read 4170 times)

0 Members and 3 Guests are viewing this topic.

Offline pyte

  • Peasant
  • *
  • Posts: 79
  • Cookies: -7
    • View Profile
python sheduled tasks scripting
« on: 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.

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

If you don't go into the tiger's cave, how will you get the cub?

Offline vezzy

  • Royal Highness
  • ****
  • Posts: 771
  • Cookies: 172
    • View Profile
Re: python sheduled tasks scripting
« Reply #1 on: 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?
Quote from: Dippy hippy
Just brushing though. I will be semi active mainly came to find a HQ botnet, like THOR or just any p2p botnet

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Re: python sheduled tasks scripting
« Reply #2 on: January 23, 2013, 03:11:26 am »
Yes, the script you posted will block until execution.
>>>import this
-----------------------------

Offline pyte

  • Peasant
  • *
  • Posts: 79
  • Cookies: -7
    • View Profile
Re: python sheduled tasks scripting
« Reply #3 on: 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.
If you don't go into the tiger's cave, how will you get the cub?

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: python sheduled tasks scripting
« Reply #4 on: January 23, 2013, 01:46:54 pm »
Maybe you should be using threads instead of blocking the main thread...