While I was searching for some good ideas to run cron job in Python and eventually I've found APScheduler.
APScheduler has three built-in scheduling systems you can use:
- Cron-style scheduling (with optional start/end times)
- Interval-based execution (runs jobs on even intervals, with optional start/end times)
- One-off delayed execution (runs jobs once, on a set date/time)
This time, I tried to get via API every 10 minutes. So APScheduler definitely holds what I want to realize. In addition to this, it's quite useful because there're some methods which start the scheduler for each environment and each framework.
$ pip install apscheduler
def hello_world(): print("Hello World!") sched = BackgroundScheduler(standalone=True,coalesce=True) sched.add_job(hello_world, 'interval', minutes=1) sched.start()
Print "Hello World!" every 10 minutes.
Top comments (0)