简体   繁体   中英

How to set time for cron job every day at 9 AM to 11 AM and 5 PM to 6PM

I want to create a Cron Job that executes twice a day for 6 days. In the morning 9 to 11 and evening from 5 to 6 on Monday to Saturday

I have tried:

@Scheduled(cron = "0/4 * 9-11 * * ?")

But then it executes every 4 seconds between 9-11 BUT also after 11.

What am I doing wrong?

Below cron expression triggers job every 4 seconds between 9AM-10:59AM and 5PM-5:59PM daily on Monday to Saturday.

@Scheduled(cron = "0/4 * 9-10,17 * * MON-SAT")

Also refer http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/crontrigger.html

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