Cron expression to perform a task twice a day at different times?

I have one task that needs to be done twice a day at different times. e.g. 10:00 and 15:30. How can I achieve this?

I am confused because the minute is different for both times. For 11:00 and 15:00 this is easy, because for both times, the minute part is the same, but for the other minute part is this possible with cron?

Thanks to Advance and apologize for the stupid question.

+4
source share
3 answers

Try the following:

0 0 10,15/12 * * ?

it will work 10:00 and 15:00.

+2
source

You can set values ​​for each task:

0 10 * * * job

30 15 * * * job

More details:

*    *    *    *    *  command to be executed
┬    ┬    ┬    ┬    ┬
β”‚    β”‚    β”‚    β”‚    β”‚
β”‚    β”‚    β”‚    β”‚    β”‚
β”‚    β”‚    β”‚    β”‚    └───── day of week (0 - 7) (0 or 7 are Sunday, or    use names)
β”‚    β”‚    β”‚    └────────── month (1 - 12)
β”‚    β”‚    └─────────────── day of month (1 - 31)
β”‚    └──────────────────── hour (0 - 23)
└───────────────────────── min (0 - 59)

cron https://en.wikipedia.org/wiki/Cron

+1

Can we type a cast of SimpleScheduleBuilder to CronScheduleBuilder?

If so, can you provide some sample code on how to type a cast.

That would be very noticeable.

Thank you in advance.

0
source

Source: https://habr.com/ru/post/1606216/


All Articles