Which Timezone to use for apschedule?

Asked

Viewed 52 times

1

I’m trying to schedule a task for weekdays, from 8hrs to 17hrs, every ten minutes, using the apscheduler module.

from apscheduler.schedulers.background import BackgroundScheduler

cron = BackgroundScheduler(daemon=True, timezone='Etc/GMT-3')
cron.add_job(service.test, trigger='cron',
             day_of_week='mon-fri', hour='7-16', minute=10)
cron.start()

but the function I pass to the Scheduler is never called. I suspect it is something related to Timezone, but I’ve tried several and none worked. someone who has been through this problem knows some solution?

1 answer

2


good evening! Here is a solution that can help you:

You can pass the string like this:

cron = BlockingScheduler(timezone="america/sao_paulo")

And find the string using thisl

from tzlocal import get_localzone
tz = get_localzone()
print(tz)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.