python apscheduler 复合触发器

Run job_function every 2 hours, but only on Saturdays and Sundays:

from apscheduler.triggers.combining import AndTrigger
from apscheduler.triggers.interval import IntervalTrigger
from apscheduler.triggers.cron import CronTrigger

trigger = AndTrigger([IntervalTrigger(hours=2),
CronTrigger(day_of_week='sat,sun')])
scheduler.add_job(job_function, trigger)

Run job_function every Monday at 2pm and every Tuesday at 3pm:
trigger = OrTrigger([CronTrigger(day_of_week='mon', hour=2),
CronTrigger(day_of_week='tue', hour=3)])
scheduler.add_job(job_function, trigger)

你可能感兴趣的:(python apscheduler 复合触发器)