0

I have a python script that I would like to run between 9 am and 4 pm everyday, but there's also a part of the same script that I'd like to run every 10 seconds during this time. How would I go about in doing this? I have looked at datetime modules, but I did not come across examples where they compare times and schedule an event. Also there seems to be some difference with the datetime module in Python 2.7 and 3.x. I am using Python 2.7. Could someone help me with this or direct me to the right sources? Thank you.

DeA
  • 1,748
  • 3
  • 22
  • 41
  • 2
    Possible duplicate of [How do I get a Cron like scheduler in Python?](http://stackoverflow.com/questions/373335/how-do-i-get-a-cron-like-scheduler-in-python) – Jezor Aug 29 '16 at 01:21
  • 1
    You could also use normal `cron` and schedule it every 10 sec but use Python date tools to detect if it was during the day and only run certain functionality. – Two-Bit Alchemist Aug 29 '16 at 01:24

1 Answers1

0

If you are using Linux,you should read crontab,it is a powerful tool to help you with schedule.
On the other hand,in Python2.7 ,try sched to schedule a repeating event .

Hope this helps.

McGrady
  • 10,869
  • 13
  • 47
  • 69