Thursday, 15 April 2010

linux - How can I set up the time to run in Python Script -


I'm trying to run my dragon script to run at specific times.

For example, I do not want to run it from 12 a.m. to 3 p.m. So it will run from 3 AM to 11 PM and sleep for 3 hours and will be gone again after 3 AM.

I do not want to kill PID, if it runs till 12 o'clock then I want it.

  is correct while ending curr_time = 'date + "% H% and sleep between times between 12 and 3 o'clock.  M $ s" ` [$ Curr_time -ge 235000 -a $ curr_time -l 030000] Going for 12000 gold then go before 12:00 to check the time so that it can be stopped before 12. Sleep for less than 3 hours because it breaks 3:00; Fired  

But the main question is. I can not think of a way to do this in dragon. Also, is there a way to wake up automatically to sleep until 3:00? How long should I sleep? Ideally you should use an existing scheduler, but if you want to sleep on your own, then

The module makes it quite straightforward:

  while importing the date time 1: now = datetime.datetime.now () if now. Be & lt; 3: at_3 = datetime.datetime.combine (datetime.date.today (), datetime.time (3)) to_sleep = (at_3 - now) .seconds time.sleep (to_sleep) # work ...  

No comments:

Post a Comment