apsheduler python is not running as scheduled

Viewed 103

The job_function isnt getting executed even once, even when i waited for more than 10 mins.

from apscheduler.schedulers.background import BackgroundScheduler
import send_mail


def job_function():
    print("Hello World")

    send_mail('abc@test.com')

sched = BackgroundScheduler()

sched.add_job(job_function, 'interval', minutes=1)

sched.start()
1 Answers

Based on this code, and this code only, the problem looks like that your program terminates before the time limit is reached.

Try adding this infinite loop at the end of your program which will prevent it to quit:

while True:
    time.sleep(1000)

Then terminate your program with CTRL+C.

Related