简体   繁体   中英

How to run a cron job every 5 minutes from Saturday 6 am to Monday 6 pm in IST?

I have written this piece of code for Saturday 6 am to Tuesday 6 am for every 5 minutes-

@Scheduled  (cron ="*/5 6-23,23,0-6 * * 6-7,1",zone="IST")

But I have to do it for Monday 6 pm .

I think you need to split it into two separate cron jobs. The first, similar to the one you already provided in your post - see this tool for explanation:

@Scheduled  (cron ="*/5 6-23,23,0-6 * * 6-7",zone="IST")

The second one for Monday, from 6 am till 6 pm:

@Scheduled  (cron ="*/5 6-18 * * 1",zone="IST")

I divide the scheduler task in 3 timings. For Saturday and Sunday 6 AM to 11 PM - @Scheduled (cron ="*/5 6-23 * * 6-7",zone="IST")

For Sunday and Monday 12 to 6 AM -

@Scheduled (cron ="* */5 0-6 * * 7,1",zone="IST")

For Monday 6 AM to 4 PM-

@Scheduled  (cron ="* */5 6-16 * * 1",zone="IST")

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