每4天运行一次作业,但现在应该首先运行

Pep*_*zza 2 apscheduler

我试图设置APScheduler每4天运行一次,但我现在需要这份工作才能开始运行.我尝试使用interval触发器,但我发现它在运行之前等待指定的时间.我还尝试使用cron以下方式:

sched = BlockingScheduler()
sched.add_executor('processpool')

@sched.scheduled_job('cron', day='*/4')
def test():
    print('running')
Run Code Online (Sandbox Code Playgroud)

我得到的最后一个想法是start_date过去使用a :

@sched.scheduled_job('interval', seconds=10, start_date=datetime.datetime.now() - datetime.timedelta(hours=4))
Run Code Online (Sandbox Code Playgroud)

但是在跑步前仍然等待10秒钟.

Ale*_*olm 6

试试这个:

@sched.scheduled_job('interval', days=4, next_run_time=datetime.datetime.now())
Run Code Online (Sandbox Code Playgroud)