(by the way, this site is one of the best forum (display) I 've seen).

I have a big issue I would like to resolve, let me explain;
I have built a script where I can put IPs into a list and then once I press 0,
this list is immediately pinged and the result of each ping are provided into the python IDLE.

But now, I would like to have this script to be started at a certain time of the day what do you suggest me ? Do you have suggestion to schedule a scritp to start ? Should I use a timer ? should I use a scheduler? (don't want windows task sked)...

Some people are providing me this script below but I have a hard time to place my parameters within this script, I don't have all the skill to perform such task as python is totally new to me. Here is the script; (where should I put my target name ?, what args should I use ?... should I use kwargs ?

tks to give me any hint...

# -*- coding: cp1252 -*-
import threading
import time

class MyTimer:
    def __init__(self, tempo, target, args= [], kwargs={}):
        self._target = target
        self._args = args
        self._kwargs = kwargs
        self._tempo = tempo

    def _run(self):
        self._timer = threading.Timer(self._tempo, self._run)
        self._target(*self._args, **self._kwargs)
    def start(self):
        self._timer = threading.Timer(self._tempo, self._run)

    def stop(self):

def affiche(unstr):
    print unstr, time.clock()

a = MyTimer(1.0, affiche, ["MyTimer"])
print u"Timer stopped"
Re: Simple question 80 80

Well, the code above appears to be intended to schedule an event within an already running program.

As it is, the scheduler itself has to be running in order for it to know to call something. Once you quit, the created threads die. So unless you could hook that code into Windows itself, you would never be able to get the *scheduler* to run. Unless you let it run 24-7 on the machine.

So could you tell us why you don't want to use the Windows task scheduler?

Hope it's clear,

Re: Simple question 80 80

thanks for your answer,

Ok, what I'm doing actually is to ping one IP to keep it under observation, and if this IP provide more than 2 % packet lost than I have to ping another list of IPs just to compare the average btwn each other for stats purposes.

I`m totally new into programmation (since 1 month) but up to know I`m able to entered all my IPs into a list and than ping all my IP(with a thread) one by one with the resulted stats in the Python IDLE. But my main concern is to activate this observation in a period of time. Let say I suspect and certain server problem btwn Sep 21 11:00 2007 to Sep 22 21:00 2007, I will need to start this IP observation bwtn this lapse of time.

If I want to use the windows sked, I will have to open my script first, put all my IPs from my python script, save it and next step will have to open the windows sked (that another thing; I cannot start it if I don't have all admin previleged ).
This will need 2 steps, by opening 2 differents application. Can I do it in python script by calling the windows skeduler ?

Another thing, I would like to use in the future, PHP to call my script for techs to be able to see the stats from the web...

What do you suggest:

a) start a timer to check the asctime each minute and if asctime = my raw_input time that call my class timeit(thread) ? doing it each minute won't take a lot of ressource I guess for 10 IPs to be check ...

b) use the windows task sked ? but how ?

Re: Simple question 80 80

Is somebody can anser this queston ?

Re: Simple question 80 80

Well, the need for admin privileges is definitely a problem, on several levels. If you don't have admin privileges to the OS, you won't be able to schedule tasks.

If you don't have admin privileges to the firewall, you may not be able to convince the firewall to let your program ping to the outside. (I could be wrong about this)

So I would talk to your admin and convince him to let you use Windows Scheduler to schedule a process to run your program nightly during the critical time window. The program itself can now spawn threads for, say, once per 10 minutes, and the threads can check the IP addresses for you.

I hope I'm not assisting a zombie pool...


Re: Simple question 80 80

Hi jrcagle,

thanks for your answer...for admin right, I don't want as I can ping anyway without any problem. I don't mind to start a timer each 60 secondes to check to local time. and if the local time = the time from my raw_input that it will work for me. what do you suggest ? I cannot believe that Python don't have such capability .

Re: Simple question 80 80

I'm lost. There's no problem with starting timers. You can use the timer in your code above to do the trick. The problem I wanted to avoid was having to run your code 24/7. That's where Windows scheduler comes in:

Use WinSched to wake your program up during the critical window.

The program itself creates a new thread every 60 seconds.

And then shuts down at the end of the critical window.

Make sense?

Re: Simple question 80 80


Ok, I know what you mean now, this a very good idea, this will save ressources.

About the code that I provided on this forum, I`m not to sure how to fill in the parameters but I will find out.

thanks again for your answers, I appreciated.

Brgds/ City One

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.