Windows XP - cron or scheduler for Python?

Tim Golden tim.golden at viacom-outdoor.co.uk
Thu Jun 24 10:42:17 CEST 2004


| I'm trying to have some scripts run periodically on Windows 
| XP and found the "Task Scheduler" did not execute my scripts. 
|  My scripts are of the form scriptName.py, and will run just 
| by invoking that name in the Command Prompt.
| 
| Has anyone used the Windows Task Scheduler to run .py 
| scripts, and if so is there some intracacy to it?
| 
| Is there a more UNIX version of a cron program one can run on Windows?


Others have already responded on using the Task Scheduler, 
and maybe you've already set yourself up that way. There
certainly are cron-like programs on Win32 (and, let's face
it, it's not hard to write your own). But I'm initially
very pleased with Irmen de Jong's Kronos from
http://www.razorvine.net/download/kronos.py.

As a test, I run the following script -- usually with
pythonw.exe to avoid an unncessary console window -- and
it pops up every two minutes with a message box. You can
obviously do anything you like with the tasks, and you
have the choice of interval-based or time-of-day-based
tasks. It wouldn't be at all hard to read the info from
a crontab-style file at startup (don't know if Irmen's
already working on anything like that).

<code>

import kronos
import win32ui

def do_reminder ():
  win32ui.MessageBox ("This is a reminder", "Reminder")

s = kronos.Scheduler ()
s.addIntervalTask (
  action = do_reminder,
  taskname = "Reminder",
  initialdelay = 0,
  interval = 120,
  processmethod = s.PM_SEQUENTIAL,
  actionargs = []
)
s.start ()
while 1:
  try:
    try:
      pass
    except KeyboardInterrupt:
      break
  finally:
    s.stop ()

</code>


TJG


________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________




More information about the Python-list mailing list