Thread: Python mod sched question

  1. #1
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329

    Python mod sched question

    I've tried asking this same question on a few other forums but I've gotten no response. Maybe the question is worded poorly? Anyhow, given the following...

    [cd@localhost oakland]$ more basic.py
    Code:
    #!/usr/bin/python
    
    import sched
    import time
    
    scheduler = sched.scheduler(time.time, time.sleep)
    
    def print_event(name):
            print 'EVENT:', time.time(), name
    
    print 'START:', time.time()
    scheduler.enter(2, 1, print_event, ('first',))
    
    scheduler.run()
    [cd@localhost oakland]$ ./basic.py
    START: 1240584506.06
    EVENT: 1240584508.06 first
    [cd@localhost oakland]$

    How do I modify basic.py so that it runs every hour on the hour on its own without using crontabs or anything like that.

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I would start by asking this question on a board dedicated to scripting languages or Python.

  3. #3
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    >How do I modify basic.py so that it runs every hour on the hour on its own without using crontabs or anything like that.
    Well, you need some sort of scheduler process like crontabs to fireup any process. If you don't want to do that. The alternative would be have a loop like...

    Code:
    while(1)
        start the scheduled process
        sleep(hr)
    end while
    This would be your demon process executing at the background. Would that be any helpful ??

    -ssharish
    Life is like riding a bicycle. To keep your balance you must keep moving - Einstein

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  3. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM