简体   繁体   中英

Spring scheduler cron expression not working

We are use spring scheduler with following setting but wondering why its not working for us?

Our expectation is it should execute every day at 2 AM, Is anything wrong with that?

<task:scheduled ref="invoiceScheduler" method="updateInvoiceStatusToOverDue" cron="0 0 2 * * ?" />

Thanks in Advance.

This cron works for my SpringBoot application: @Scheduled(cron = "0 0 2 1/1 * *")

Btw, what "doesn't work"? Could you please elaborate?

The following task is being scheduled to run 10 minutes past each hour but only during the 8-to-5 "business hours" on weekdays.

scheduler.schedule(task, new CronTrigger("0 10 8-17 * * MON-FRI"));

Could you please try this:

scheduler.schedule(task, new CronTrigger("0 1 2 * * MON-FRI"));

OR

scheduler.schedule(task, new CronTrigger("0 1 2 * * *"));

"0 0 2 * * *" instead of "0 0 2 * * ?" helped us to achieve scheduler to invoke every day at 2 AM. Thanks everyone for finding time and helping me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM